此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
& L( K" u: }+ i, }, h) e& g 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。9 }1 M, I) U* F8 F3 @: L+ t$ F# i
方式一:- f) d+ A$ R% V% X' J" P- t
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,. |) X' Y" F6 J7 Z; A
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和2 a' v1 n' Z L. g" s
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。& b' [! w2 Z7 {0 O% g
方式二:# ]5 H x5 v. b' _
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
L/ F' w7 h2 P9 z SetTitleMatchMode RegEx8 x% Y) y( f* n( N' y
return
& Y9 h7 M5 \+ \0 n; W7 J ; Stuff to do when Windows Explorer is open
/ ?% T3 z7 `+ m0 D% Z/ J ;( R0 c9 v1 d) ~$ x; I C7 k
#IfWinActive ahk_class ExploreWClass|CabinetWClass) O+ `( h+ N: J- I r- H
; open ‘cmd’ in the current directory; w% e* y9 ]; c5 ~% ?
;
) k2 z7 {* x }6 W0 b6 F# V #c::
, i4 K0 l6 k$ i% _) l! V {5 X( | OpenCmdInCurrent()0 {0 l9 R0 ^$ R
return
$ f7 |5 d7 d; o; Y" R1 L( I) y3 c #IfWinActive
. @5 {* g& H9 b- Q ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
9 h6 ?3 C4 G1 p3 ?% j ; Note: expecting to be run when the active window is Explorer.6 Y9 {5 M( K( W' {. ]5 b! ~4 q
;' Z! a2 E- i, X8 R) G% {0 @
OpenCmdInCurrent()
- _( o) T9 P% S; f8 V! ?' V {# u |! c/ `, S* _7 C/ G9 G
; This is required to get the full path of the file from the address bar/ K1 L+ G3 U& B
WinGetText, full_path, A
( u* O2 O; S$ Y. A9 Q ; Split on newline (`n)- y7 O& ?' c# P6 P7 C
StringSplit, word_array, full_path, `n; F; B9 z" `% C6 j/ S( M* n0 `% O
; Take the first element from the array0 V9 H9 G+ S7 Q# K1 y; u7 F6 l
full_path = %word_array1%
8 V' B, t' Z# z7 c; T Y( R! M ; strip to bare address
' Y3 W+ @* t9 T, f! R! z' | full_path := RegExReplace(full_path, “地址: “, “”)
( d8 ?% D$ S' Y ; Just in case – remove all carriage returns (`r)
( F3 Y, P6 Y7 A& T4 B% |7 S& Y StringReplace, full_path, full_path, `r, , all/ u7 q2 d, b1 ^1 S/ G+ [! y
IfInString full_path, \
5 m3 t; H7 z' M, H6 O# A {% X# [. X5 ?$ x; d$ E. b
Run, cmd /K cd /D “%full_path%”
# e/ z- [3 T7 r }+ c/ C6 Q/ R/ q( N3 |; m3 r
else
$ ]- k: B2 t% ~$ e7 W' b {, B' Q1 c6 L. b' q' i
Run, cmd /K cd /D “C:\ ”; d& V5 T) w; j( Z5 H' R V
}' }1 b T# O5 n) H; A
}2 a4 I( h- ]+ @1 C1 N2 @
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。7 ]& C' x& O* J7 L
这段小代码肯能有两个你需要修改的地方# J% ~! M. F& Q4 ]# M( T
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
- u; S/ C; y# D, E6 r5 |& M6 P 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “/ R$ C" b2 M/ a/ F: j2 J
|