此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
3 l7 G( P1 l# N5 p8 P/ I& ] 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
. X* M3 @4 }, D6 N 方式一:8 G* N* O! Y5 ]* y1 ^& x
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,) I; Z; ~! B6 p$ B4 M" a
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
0 h! ]' S0 u& Q! ` HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
* x" Q7 V! g9 B( U6 H 方式二:' p. |' ~5 N9 x$ @* G
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:4 j! t. |% M7 I8 Q, F, L
SetTitleMatchMode RegEx
0 ]% z0 n1 I4 Z" y& \) M return5 i! d% a) z) B+ F0 z
; Stuff to do when Windows Explorer is open5 W& @& F g9 k& f+ y* k
;% W9 B8 G( T9 B" Z$ m5 E* B7 A
#IfWinActive ahk_class ExploreWClass|CabinetWClass
' a* e( w6 p+ q6 k7 r1 h% ]0 [7 { ; open ‘cmd’ in the current directory A/ ]/ g4 [4 T( ]1 U
;) W1 U: K# R$ g' n9 D( z! f8 b
#c::
$ V) o: V; Y7 X OpenCmdInCurrent()
0 U" [* v) Y* s return2 L6 }) w: R, Z
#IfWinActive8 |2 `9 K% z( P+ i; j
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.& g. [) N: `7 p7 q) s
; Note: expecting to be run when the active window is Explorer.* _+ V7 b% e7 p' c* `& W/ K/ Q' |& l
;, ^2 H7 a1 u! o# c5 O( X5 ~1 _: e
OpenCmdInCurrent()
; f6 L% h5 K5 O, N {7 q' W2 @7 u: g: _9 |/ R* k
; This is required to get the full path of the file from the address bar+ L; p6 X& C" H( f. z
WinGetText, full_path, A1 d, F% L B' O) p) i* T
; Split on newline (`n)
. X; S! M/ O* {8 d9 a! Z StringSplit, word_array, full_path, `n( q5 p0 E/ A y" Z4 w; \
; Take the first element from the array
' h4 m/ L4 k* O; Y1 }" {7 E9 e8 v full_path = %word_array1%& W* U6 F$ D8 n! l" i; | d( P
; strip to bare address
7 U6 ?/ }& S4 d' a! |0 {3 P full_path := RegExReplace(full_path, “地址: “, “”)- [3 R m1 o# C. W
; Just in case – remove all carriage returns (`r)4 _4 F' W7 s$ X+ b: ]. @2 F
StringReplace, full_path, full_path, `r, , all9 a& c; C% q2 m9 }( [
IfInString full_path, \/ W: ]/ z* ?; i( o) c' r% M
{# W9 m, V% D9 `. J0 G6 F
Run, cmd /K cd /D “%full_path%”9 N) o1 `, n& p$ Y; F, n7 h
}
1 W, J. c) ~( E else3 \1 ^+ |$ d2 H
{3 v) [ C9 c, {* P+ \+ a: ?
Run, cmd /K cd /D “C:\ ”3 [) b6 A; F: ?
}
8 x+ X+ k# D- ^% B- m }
" O$ \$ C, c' D; h4 O D. ~ 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
1 ~1 q9 @6 I# r* ?: r5 c! Q 这段小代码肯能有两个你需要修改的地方+ W& b2 _3 P- q, [- c9 F" ? e
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键0 K/ t) o6 V# p6 v) \
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “' }9 F6 V% `% q
|