此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。4 d, j0 [2 \, @: H( d5 `/ E
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
. h2 O- ~' d M! D$ g; ^1 H 方式一:; v( h4 `4 h& M" d3 e' `- G( z2 |
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
7 f f; {1 {8 [" Q 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和9 x, F# a9 x7 S( h3 s( w2 r. O! S
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
6 Z7 `6 J6 a; F7 i% ?4 G9 f 方式二:
8 c" ^! b, f) K/ j" o) {$ F9 i- C( a5 U 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下: k$ S) \8 @, f& J/ I
SetTitleMatchMode RegEx/ W/ X+ }5 N N" f
return
4 g: F9 b a) z ; Stuff to do when Windows Explorer is open" \: S2 T! v% N- k: p
;
- t" V- r4 i6 e& v7 E5 T #IfWinActive ahk_class ExploreWClass|CabinetWClass0 F6 f2 s# L/ N1 t6 e- _
; open ‘cmd’ in the current directory# U* l8 P9 S$ K: n) }
;
; V+ |( M0 Q4 c0 I( G8 R #c::0 h- O$ \' j2 n. A. D
OpenCmdInCurrent()
9 ]6 E0 W- p) P4 n return
: i3 A7 J+ a8 F6 p #IfWinActive) a B' e/ D& n6 I# d. [7 ?0 S& n
; Opens the command shell ‘cmd’ in the directory browsed in Explorer." o( \8 }9 O( ?$ q
; Note: expecting to be run when the active window is Explorer.
, g5 l1 C$ X1 Y/ j1 V, Z3 j0 b6 P3 k ;
& \9 v# Q2 ?" L2 V OpenCmdInCurrent()
/ m6 k5 V2 I8 [6 u1 ^8 K/ f {
) H# h; u' C* ? E ; This is required to get the full path of the file from the address bar& _! `. ]% i O p% g; v6 ?
WinGetText, full_path, A/ Y5 ^0 W( Z( T6 i" T$ S
; Split on newline (`n), a- i$ M& B; n s) C5 s3 Y
StringSplit, word_array, full_path, `n
- c' U" p w+ t3 }8 \' a& ?$ R/ A ; Take the first element from the array. S* Y0 h5 u% ]
full_path = %word_array1%
' Z: R3 L: A- P/ ^4 y7 @ ; strip to bare address0 q+ O: o! j2 q. Y- G: h6 l
full_path := RegExReplace(full_path, “地址: “, “”)
# U* v2 c1 Y( Q9 \* b6 d# w5 K ; Just in case – remove all carriage returns (`r)5 q+ ~ B) L1 k0 n4 X
StringReplace, full_path, full_path, `r, , all- h: r2 {8 \ v6 I
IfInString full_path, \
4 ], B4 \+ ^7 I1 H& k$ Y" \ {. l3 O+ H- \. B$ p* M. c
Run, cmd /K cd /D “%full_path%”" C( I/ I, ]- \' g4 V
}
# F% Q1 }! ?# V# U5 p. b% ^ else
# v# X7 R# v8 ]4 g {
$ u& z0 c! A# _, n. j Run, cmd /K cd /D “C:\ ”- k! B* k! W" C1 _0 t6 x
}
' }: f: N' O' _5 c# D }
" X& ]5 D9 Q# s o% t8 z 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。0 o6 h, {* c9 \! H% x
这段小代码肯能有两个你需要修改的地方
$ I3 E4 A$ `: C7 F0 t6 K7 o 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键. V. I5 l3 p" ]1 Y
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
% H+ T4 }/ |6 k. D% b4 \ |