此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。9 J0 E S5 ?3 b9 i Z" Z: g
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。 T- W) p% K1 e" m
方式一:
4 u6 ?7 x; _# h' T- J9 [2 m 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,2 S' o: B" ?- z% c& K9 b
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
# q& e, ?/ z+ p! x% b$ Z HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
; ~! `1 Q' O, a2 g: z 方式二:
_8 P% x# R) X+ ~6 x; `6 a 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
; C$ b$ t3 M' ~ SetTitleMatchMode RegEx& F" }" K1 |3 b& ^# e
return8 E9 a6 @" W v k$ G* F* B5 s
; Stuff to do when Windows Explorer is open
& q) Z* C3 h7 a$ e2 J1 K( L& j ;/ a" K7 u/ f& F# G) g% @0 o
#IfWinActive ahk_class ExploreWClass|CabinetWClass
3 |3 ], ]8 ~7 d8 u; ^ ; open ‘cmd’ in the current directory" e0 {9 R; ~9 g1 z, G; R
;
3 O# l/ |: i: e( }9 D# s# v0 ` #c::
+ L) G, q" H5 l3 J$ s* d/ E OpenCmdInCurrent(). H( A$ W) G9 J) E7 W& m- ?* [1 I& Q
return
! i- T% _2 t$ K. {) p #IfWinActive2 X/ e: W% e Q/ m' @. N, L6 s
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.; M# A& i* q# Z* {& @8 X% n$ S+ ]
; Note: expecting to be run when the active window is Explorer." r% I/ }+ h( F3 R) I* m
;; o+ @- k% k8 N; ?) [; L. y
OpenCmdInCurrent()" h3 {2 h, ?# P. z4 i/ Z6 V, H
{
- d' _/ g+ w! s( J7 l ; This is required to get the full path of the file from the address bar
3 ?6 _" T2 s5 d WinGetText, full_path, A4 G* ~0 L1 W1 G
; Split on newline (`n)/ `& J9 @5 O! N; a
StringSplit, word_array, full_path, `n9 E+ f; g n* {; k0 L
; Take the first element from the array2 u. @5 N; |7 _# X \9 x& O1 O
full_path = %word_array1%% l* K% c+ J; G" s: \% g; t9 P
; strip to bare address
" l% V# k7 i; h+ r full_path := RegExReplace(full_path, “地址: “, “”)8 U+ p: D1 X5 }5 P# g
; Just in case – remove all carriage returns (`r)( }. v6 C2 k+ w9 ~$ y
StringReplace, full_path, full_path, `r, , all
0 F4 g1 x! o* A# X7 }' `* N _ IfInString full_path, \3 |% [; X5 p9 Y4 A3 ?. o
{
! t- u$ O+ ?0 ^% M H* w Run, cmd /K cd /D “%full_path%”, ?# I2 b1 y; O. L. |: J3 b
}
0 [8 j$ m+ Q5 g) ^1 O1 J else
, g4 }) D7 a9 C+ E- k: y {9 G2 B$ u% t G! A" t7 J9 R
Run, cmd /K cd /D “C:\ ” U3 S4 C. ~$ P6 L3 b. |' R
}" U# C. W% ?; r) X: ]+ {
}
$ c1 j2 s" F# S6 Z& u: F$ ^1 o 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。' ~' L, L2 S2 o( Q
这段小代码肯能有两个你需要修改的地方8 n- E. P) j. L6 @5 `; p2 Q* R
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
! z, @, A6 K6 |- y6 s$ c% i 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
. W/ a7 A& x* z+ A2 I |