此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。" ]% R' T7 x: F* H" j: O [: e, w
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。/ Y U! b/ j8 ?& j4 u
方式一:
: _' m4 u( j$ @ \; G" A- ? 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,: v- \% V! }) Z/ a: _- {# K! C
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
+ X( f/ X# K' N0 e) N5 U HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。: O5 d# p( o( g1 t$ U' R
方式二:
9 }5 H, {% Q. h) z: ] 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
3 o$ ^2 h( D: N8 T# g SetTitleMatchMode RegEx
" E8 F7 b) n2 S8 a, t: w return3 J0 A6 @/ M$ }' G+ o" I# s7 o
; Stuff to do when Windows Explorer is open
4 Y6 V# w1 [& k2 Z: q ;
: C3 P# e5 H/ ^+ h) O* v #IfWinActive ahk_class ExploreWClass|CabinetWClass: p" t; g% m- S& V: G! G
; open ‘cmd’ in the current directory7 t% \3 |: F3 w& P
;
; S4 T+ y9 j8 X# N$ v/ e. H0 Y& g( C #c::
( U. S$ t" k% ^2 A! V2 n) _ OpenCmdInCurrent()
+ A* o5 ]% f. {3 w# o return
% ]8 Y8 b: [2 a9 C* c5 f #IfWinActive2 ]0 o- W2 U9 P" D" a ]
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
. M' M" a2 B* m. @ ; Note: expecting to be run when the active window is Explorer.% w5 X7 X4 H3 H
;; ~# C; q( u7 Z9 Q# t
OpenCmdInCurrent()
2 ]2 K2 C F9 c {
! J' v9 _* u: c9 {( h$ R ; This is required to get the full path of the file from the address bar' [, L$ Q( C: V/ |# N8 I
WinGetText, full_path, A* e) k4 {, w$ Y$ l S' d
; Split on newline (`n)
6 g& f, q% C2 Z StringSplit, word_array, full_path, `n* K# G- v* T0 }# P
; Take the first element from the array8 d/ E8 \+ g, w) F. Q! Z0 K
full_path = %word_array1%$ s* J; t1 x! C0 x# J6 M# z- X
; strip to bare address
& Z; S% _1 s5 G" ?# |$ W full_path := RegExReplace(full_path, “地址: “, “”)5 m: ~: s1 Q* [/ G% u0 L% O- C
; Just in case – remove all carriage returns (`r)
# L& j) R% |! U) R: W StringReplace, full_path, full_path, `r, , all- Z( }6 h$ F( G& ^6 a
IfInString full_path, \; `5 P0 | t1 o$ H
{7 M5 f; E, j4 K) D
Run, cmd /K cd /D “%full_path%”
" ]. a1 j5 h' i) P. D& F6 T }" `+ H k0 m: |8 _8 J
else6 I$ r, Y/ N M8 N6 d
{
5 S- T2 Q# _; Z; ?4 q0 ~4 x Run, cmd /K cd /D “C:\ ”6 {& z% m6 n s: K t0 W6 t+ U8 P# b
}+ w5 s4 T, B3 J. O' q0 m1 l
}* P1 | C) [+ @1 K1 w3 s
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
# |0 F* E3 e3 D) G' p s! q6 { 这段小代码肯能有两个你需要修改的地方
; C4 s' B! l4 J/ d7 S 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键& q' W2 N5 {1 V/ i
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
. Y, L7 V+ `" I# K2 j/ X |