此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。! v5 J/ e5 \' X. Y& Z- r& O
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
+ I1 J) e+ i# _/ m8 l0 E 方式一:
/ R5 i) a4 ^& e 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
0 S4 w. ?( h" ~% m5 f/ w 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
& Z. X5 ]7 E, f0 R- d) `3 l. s HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。! y& e) b, ?( S5 z5 _; X
方式二:
% _6 \. A y* x! M# E 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:( o% V/ m+ n% h3 s6 I" \) R
SetTitleMatchMode RegEx
# w% U: Z3 A0 ^ Z1 u9 Y return
" \4 d; ?) z4 m ; Stuff to do when Windows Explorer is open3 b+ {0 [# }( T) [+ p* _4 w
;
& T8 ~+ c, r5 i t #IfWinActive ahk_class ExploreWClass|CabinetWClass3 q% k% `7 `" a+ f% [
; open ‘cmd’ in the current directory
# X2 ^5 {; c4 p9 ` ;
1 \$ @( ~2 h; n. y0 `! X6 x #c::
) Z5 V6 l9 ~0 V% Y( j' h5 u1 l# B OpenCmdInCurrent()
2 u. T" X& i2 m' A return; n7 P5 Z0 q( W( `4 j, v
#IfWinActive
+ x5 d9 [3 @- D* F( e; i ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
j E+ Q- K( c; i1 O! ]- S ; Note: expecting to be run when the active window is Explorer.
* U& K3 c! V+ f p a) r- a3 I9 t ;4 M! |! e# Y5 |. t2 P+ a$ Y
OpenCmdInCurrent()" x! |) r! m, }' I6 |$ K& }; I# P
{8 p' n( Z9 k O& d: E
; This is required to get the full path of the file from the address bar/ t& y. S; j8 S2 a0 h% { h. y
WinGetText, full_path, A4 Q" u$ G& M2 O
; Split on newline (`n)% o+ p0 r$ B' {5 M- n6 T
StringSplit, word_array, full_path, `n4 D# C: V3 @+ E/ A$ P, j
; Take the first element from the array
' K: Z- u- `; z' w5 ] full_path = %word_array1%
: p5 P E5 d# f: R- J ; strip to bare address
0 v, I( Y% D1 O6 i% A o" F- }4 }; y full_path := RegExReplace(full_path, “地址: “, “”)0 I% _' r3 D; ~; f
; Just in case – remove all carriage returns (`r)/ V# r2 K# T+ y! b. t% f+ Z) L
StringReplace, full_path, full_path, `r, , all
/ @% e& ~/ X8 H0 ? IfInString full_path, \
( C2 \/ H* ]& ~2 e {
7 t `+ K( U2 ]0 K& p Run, cmd /K cd /D “%full_path%”
6 s8 V* @4 S3 F: K' m }1 S Q+ M& t9 v( Q |" p+ h
else
) u- U( K Q7 D4 V1 v {! @1 U+ B" j6 R
Run, cmd /K cd /D “C:\ ”
) }* i/ E& r8 j% M: A3 s7 B7 G' u0 O( } }
' L: F4 P+ ^5 I4 e }0 C8 L f1 y. B4 I* h9 m
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。8 ~- e6 u' r9 q' S1 q; {
这段小代码肯能有两个你需要修改的地方
( Y2 ^$ k: @2 s 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
4 c$ ~6 n) s& w- \1 h) t% T 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
3 F" O6 ~8 w& V" Z# U |