此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。/ W& J$ ?& P4 b$ n# l# e9 q5 o
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
8 e9 @0 N' ~2 T* v 方式一:9 p3 {# R& R+ Q. ]8 I% ?4 J
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,/ P, W) @. k% V
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和" P/ R" U) p; i) p! q# Z
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
+ o; Y. U% S/ ~ J 方式二:( K p7 i" R$ p
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
9 J( e W9 i& \2 z SetTitleMatchMode RegEx
0 |; h' [# C8 y- N return1 J+ r; F7 D- U7 j( X) @4 _
; Stuff to do when Windows Explorer is open
. L' P( y0 m" ] ;7 T& B! b3 \1 y. u, m
#IfWinActive ahk_class ExploreWClass|CabinetWClass
' Z: u' Y m3 j ; open ‘cmd’ in the current directory
7 s& [! A' x$ O! j( t/ @/ Y( Z6 d7 ` ;
( }7 b3 {4 j! U$ J #c::( w5 J; f; C( F4 H6 u2 ?( V6 ]
OpenCmdInCurrent()
( O, P# I5 F; k g7 R0 i return4 c: L! K2 p; y- c4 h. u& }
#IfWinActive
2 X$ ~! d7 h" x" F4 L- g ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.& H4 ~0 \# c4 d3 G- j5 A+ T
; Note: expecting to be run when the active window is Explorer.! u2 q3 F3 P: Z5 U- U1 C/ ~1 D: w
;' I' U/ m4 h' D
OpenCmdInCurrent()
& J' x8 w! B/ B) B6 x {) b4 Q/ X8 i, x5 a7 q) G
; This is required to get the full path of the file from the address bar* u0 \# E a/ _$ F6 c, ~
WinGetText, full_path, A
# D0 \9 ^& X2 ]3 u5 X7 l ; Split on newline (`n)
( S* p+ T/ q" H+ D StringSplit, word_array, full_path, `n) D o; K5 d9 R0 r; {# q) a$ ]
; Take the first element from the array
4 j: ^4 P( L; j, `" ^4 `4 r full_path = %word_array1%- a4 G. @# ?; ~
; strip to bare address U, w) x4 b! F! |" z0 Q
full_path := RegExReplace(full_path, “地址: “, “”)
( b$ M/ g7 @7 m; r8 }& | ; Just in case – remove all carriage returns (`r)9 ~3 @8 `' u3 P. k' |0 e
StringReplace, full_path, full_path, `r, , all2 z8 F8 i- s) t) R5 b
IfInString full_path, \# ~& B% |8 A; R$ O/ P% V5 w
{! S3 c4 Z" e) X3 x3 ~) S
Run, cmd /K cd /D “%full_path%”2 z! G9 a0 S5 R
}* ~* b$ e. ^. y" c+ J
else
: X' u' e) e- i9 _9 A2 g* b& e; K3 c4 X { f7 L% o' B6 F- G! k/ y- n8 R. K
Run, cmd /K cd /D “C:\ ”
0 A# T8 W- [: U1 D }: C; e2 ]0 ~5 i9 ^3 R# i
}) M- ~; g. b! f7 G' q$ K1 ]( g
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。' C% k/ F) T+ T" I0 Y
这段小代码肯能有两个你需要修改的地方
2 K$ z- D X3 @, { 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键2 y6 c, [( G4 V
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
2 z; K/ A9 W3 m! Y2 f& r" ~3 R |