此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。( I5 G: R% ~$ j" f% R
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
3 N" t$ G4 g, C1 q1 M t 方式一: u$ l5 y/ `% y1 ^+ C- @
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,$ D$ Z6 x9 l- R3 I
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和3 k/ f1 N8 K# O$ ]) d. |0 }+ a
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。4 }$ J! G h* W# Z
方式二:
$ {+ [3 m' _1 A8 l 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:) d. k2 t0 ^) G, o( Y0 K2 P7 Y' j
SetTitleMatchMode RegEx& J1 x( k) y# y" c
return
2 n' ?- M" Z; N" @ ; Stuff to do when Windows Explorer is open
1 r* u) z- g( Y7 q ;
: ?/ _3 G- K' {4 }. U; b- O% \9 ~ #IfWinActive ahk_class ExploreWClass|CabinetWClass
- ~) u5 g9 N% _6 ~2 E( i$ A ; open ‘cmd’ in the current directory5 N. M) \ @% B! k- b
;
( j1 ^7 m8 m2 \1 _3 y8 Q #c::( a! L. J0 H, ^ s, |( h, \
OpenCmdInCurrent()( x, n' Z) K- Z5 X3 U& ]) n; D
return4 a% T o1 P" N3 b
#IfWinActive2 v2 }/ E4 [8 D" @& L c8 n
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.6 y b1 H- X+ o2 J! N
; Note: expecting to be run when the active window is Explorer.
2 z0 ^' q" F8 ]2 E% M" z8 L6 w% ` ;
$ |* S* ~ J* h/ E OpenCmdInCurrent()- k7 ?2 K1 g. d/ P; ^7 ?
{; p$ y/ a% Z4 d
; This is required to get the full path of the file from the address bar, v; C; T$ N4 \1 Q+ K5 c1 S
WinGetText, full_path, A7 F4 k8 H4 { X V' M: i
; Split on newline (`n)
: d$ Y) w( i' P0 w9 g9 |7 O( t+ w StringSplit, word_array, full_path, `n
+ |. X6 `3 A8 a* ^! p* e ; Take the first element from the array* X7 S9 v) D9 v& V
full_path = %word_array1%* e" k o( O" `
; strip to bare address+ J. X( D8 i( J5 `' X! `
full_path := RegExReplace(full_path, “地址: “, “”), V' N) m; H8 i0 r8 B4 ^
; Just in case – remove all carriage returns (`r)
& r* H: N) q+ |4 v2 W1 f StringReplace, full_path, full_path, `r, , all5 o( ~# k6 ^7 g6 e6 L5 C
IfInString full_path, \
j3 v G2 k( k4 ^ {
0 j0 l# s' T/ y" n+ X' c Run, cmd /K cd /D “%full_path%”
6 A$ v5 H; W* w4 [ }; y9 t# V( t" u/ `
else
/ d/ C7 C# {, o7 u {
# D+ |! i" X, A Run, cmd /K cd /D “C:\ ”5 }( {4 I7 H' w* a
}0 X+ z; z( \' I+ c" T# `, h, L
}8 ^2 @6 c+ m- Q* U; R/ r7 j
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
+ v2 `" M4 V, V* R3 W 这段小代码肯能有两个你需要修改的地方
' V* [; H% |; d2 b" Z 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
6 F- R' _& o2 x: X3 m 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
: W( B. B9 G; W4 A* l |