此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
2 [+ \ g3 F7 }. u+ ~ 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
* Z! a1 I8 o% q! M! v3 m, Q 方式一:
7 i$ [5 `+ _% r3 Z 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
- k* ]0 q$ I' c% \+ [7 b 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和' {* z6 s: O2 u% B; O1 J1 H& g
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。, z+ M1 ~4 W9 ^5 g; U
方式二:
+ k- {7 [! a$ G" Z 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:6 b- c2 N2 K b) O* ]
SetTitleMatchMode RegEx7 s/ ^+ X: N4 c( I1 q9 y
return z, ^7 K4 Z3 j& F
; Stuff to do when Windows Explorer is open
, ^6 ]; u4 ~: } o6 P ;# N/ ]% S0 V3 M6 t
#IfWinActive ahk_class ExploreWClass|CabinetWClass
* F3 N" M1 E% [: F0 _1 k( A8 l ; open ‘cmd’ in the current directory, a/ H# O' g6 Y x8 F& P
; x4 j' L. @$ n
#c::
0 _& Y, Z: W' ]0 e OpenCmdInCurrent()
' z5 C8 _3 z; \: {# @ return
! C, [" l& r5 P ^ #IfWinActive
( w4 V. b; X5 R ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.$ T; W3 f& E& f( h: ~
; Note: expecting to be run when the active window is Explorer." ^4 p; O6 y6 B) y8 }
;
( l# }9 D! A/ T. }8 _ OpenCmdInCurrent()
* P1 O7 K1 [* B% m" A' R {! l$ u+ l: C+ j% _$ l
; This is required to get the full path of the file from the address bar
$ X+ |+ ?8 V; l$ l WinGetText, full_path, A, F" Q) F' b& j% ^; ^
; Split on newline (`n)
- ~) v) r3 @3 `% x StringSplit, word_array, full_path, `n# n4 S V% ^/ i x0 ?
; Take the first element from the array2 n" B3 t! O! N' `1 S
full_path = %word_array1%% J$ Z0 Z. {& g. Y, |1 N$ l
; strip to bare address
6 z+ k) t( |8 G! h7 C full_path := RegExReplace(full_path, “地址: “, “”)7 x" C3 t% Y `, R) ]" m. v
; Just in case – remove all carriage returns (`r)
# z' A! E7 L! R, o9 D4 ~ StringReplace, full_path, full_path, `r, , all
5 o+ e" A: a# }5 A, s IfInString full_path, \
; ^) o+ i5 w g& e2 Y1 ^ {
0 J1 ~: a F) [& r2 j9 \0 M Run, cmd /K cd /D “%full_path%”3 E: s) _/ _7 w7 D5 Y
}
) x* ]" n0 x# c0 v else
4 b, {2 n: t1 e# I( i {
$ G0 R5 w: w( W" g! z$ C: | Run, cmd /K cd /D “C:\ ”9 K4 W0 r5 c% O N0 k0 z
}
% s4 h( Y# g$ x% m3 S, I" p }
# f5 u) z8 z; ^1 V2 M% p 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
; ^3 P$ u8 `6 o& t6 K0 Z 这段小代码肯能有两个你需要修改的地方4 U4 R$ C1 Y* ]& w$ b
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键7 V" x, w3 Z- r' t, {. Z' T' T
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
9 y! B8 S- F) F |