此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
& ]0 }% M# A4 [1 C. B 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
. W+ L- y7 h. Y# a/ M3 O( F, a 方式一:( ~2 o8 @. `+ c4 _7 d$ p9 _' S; p
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
5 c. [# U! v5 v L( @ 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
1 V; a. K8 I0 g" U* u HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
6 e9 }' U: P- C4 I 方式二:6 \" c( v& h0 I1 d
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:6 X4 [ p0 s. N) Q: ^+ j
SetTitleMatchMode RegEx: W. G. O! B( [9 b7 u) ?
return
" c4 ]6 Z( j, n" p: ` ; Stuff to do when Windows Explorer is open0 q1 }. ?& I9 r6 S6 j+ P+ s
;
1 T$ r" ^- ]' `" H$ e+ u4 `! ? #IfWinActive ahk_class ExploreWClass|CabinetWClass
$ j! z* V& ?! R3 d" j ; open ‘cmd’ in the current directory
. x! e/ f* Z% A" v V ;" Q5 T; O1 Q, |0 J( l/ ^
#c::/ A+ ~0 d0 g' Y# w4 E* [5 _8 ~
OpenCmdInCurrent()
# j( u# u4 E: P& N: L return* N" P& G" E. m; g! |# l* {( B7 H
#IfWinActive
k, _1 i9 L+ a9 U U ; Opens the command shell ‘cmd’ in the directory browsed in Explorer./ h' M6 \: C+ O" \ w6 k
; Note: expecting to be run when the active window is Explorer.
- r2 a z- W+ p7 z) C, s: G% q% F ;
" l! i# I$ \5 | OpenCmdInCurrent()( L2 S0 `7 F2 T5 W% _+ z
{$ J& J* T D6 h l c
; This is required to get the full path of the file from the address bar6 J) @4 _/ I8 N# o( m( J
WinGetText, full_path, A
. p6 q" O1 k4 K B% l ; Split on newline (`n)+ o4 o- Y C/ A b5 M
StringSplit, word_array, full_path, `n
+ Z% `5 F1 ? K/ B. n) N ; Take the first element from the array) O* ]+ a4 R' L4 x
full_path = %word_array1%1 P' j3 R0 p; [. h* c
; strip to bare address3 O* O( |, N9 S+ g% V0 u
full_path := RegExReplace(full_path, “地址: “, “”)7 c2 y* N$ F' A: i
; Just in case – remove all carriage returns (`r)1 ^! q9 F$ K0 m6 `
StringReplace, full_path, full_path, `r, , all1 d, I+ W w) C, s0 s% R9 k% |. S
IfInString full_path, \
5 \* z- n ~) M. a* C7 R {
# T) t. X% c! J# K Run, cmd /K cd /D “%full_path%”
$ _7 I* `$ m2 { }5 C$ v( ^. m, E& ?3 a ]* o* t
else+ V; q+ M1 V ]
{" b1 r p8 |' B0 h
Run, cmd /K cd /D “C:\ ”
. D9 ^5 e$ B( V f8 {. z$ M }, _! n1 T3 ~& k; V
}
- q3 n" L0 w! Q4 ] 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。3 `! y; i7 G" y, j: l
这段小代码肯能有两个你需要修改的地方9 o0 J; m5 @1 S% }
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
: V0 H% x6 r- ], n) H% `- C 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
/ N: p. |+ B) B* a, C9 P |