此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。! B8 d' }; J7 m2 t. J
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
5 T. _$ j5 h0 F( S7 h 方式一:1 W$ P- ^! P2 U- j
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,$ S- Z) v' D: Q; t$ J8 q+ y
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
( s1 S, N$ ^+ V0 s HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。- X. f: l9 S1 R1 r( x0 u
方式二:
; O$ W" n `% Q1 o- k 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:' e" ~6 u$ a- I G1 k
SetTitleMatchMode RegEx0 z8 k u0 P; m; r u/ X
return
1 b9 F1 {2 i% q5 u2 G8 d: o- Z" f+ R" t ; Stuff to do when Windows Explorer is open) e; G) {! b9 e4 |; S5 s( M5 v8 Q; s
;3 R% l( p& @$ H: q$ ?4 ]; b
#IfWinActive ahk_class ExploreWClass|CabinetWClass6 a! C: u5 q7 d( W/ W; x0 w
; open ‘cmd’ in the current directory
, {9 Y' G- s9 M' f/ \ ; T$ n f3 ]) a9 y" H
#c::( K: E6 T* o; G9 s" H9 E7 d
OpenCmdInCurrent() a, t6 Y/ r. ?/ H7 \) j' {! W! j
return
2 [; ~' P: I ]2 ? #IfWinActive$ ?6 ?$ G* E5 K9 K ?( G3 Y: t
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
( j" z% i/ R. h5 m' d# M ; Note: expecting to be run when the active window is Explorer.
( T; B! a# a T- x$ E, Q, M7 R( ?0 i ;
; N x; Q' I2 U0 W OpenCmdInCurrent()
0 s3 S4 \2 a5 F- c/ g0 B9 N {; U4 t: ^9 j6 R- U- c# T
; This is required to get the full path of the file from the address bar
' R k9 ^9 b& `; f$ h* ^# _ WinGetText, full_path, A
6 B' \/ `) K: U- s9 u ; Split on newline (`n)
; B7 d" P! X; z1 V StringSplit, word_array, full_path, `n
1 ~/ Z( h' W; L1 s6 W ; Take the first element from the array
# j. Q/ C( b) h) P# S full_path = %word_array1%* l- {& [% ]) w _$ z/ s) g
; strip to bare address% q# ]" y( z$ \- H
full_path := RegExReplace(full_path, “地址: “, “”)
6 g" S; ?1 O3 j5 _' t0 X ; Just in case – remove all carriage returns (`r)
( W9 s* U4 N0 @$ H2 l& i% W7 f StringReplace, full_path, full_path, `r, , all
/ x) G1 C* ^* L+ p" j IfInString full_path, \# ^9 X0 r7 O: `) W) C
{2 F2 Z( f1 n4 i4 a8 j+ z
Run, cmd /K cd /D “%full_path%”
; s( Y! D+ X: ^2 D2 c, W9 O }
% {5 `: k* Q9 f8 M8 C else2 G2 ]; Z1 U5 E5 M$ z
{2 x& l+ H4 f& M. V
Run, cmd /K cd /D “C:\ ”7 [, r; {" f& D4 _: X8 H
}
8 I1 j; X3 F) y8 F2 Z# x4 x ^7 Z }% V! e0 o( y7 y0 U& L+ w
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
0 I+ j. L( m# o9 |+ t2 l' a 这段小代码肯能有两个你需要修改的地方
7 [7 G: r; q- {. s1 [ 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键, g+ ]- o! u% o
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
+ `' Z8 w5 x* E' @# x |