此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
- l* {- }5 E: F8 o5 e/ P1 U 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
- Z& \& v9 x9 b# A$ u9 h8 { 方式一:/ `' c0 p- |! } L! s. ^
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
9 s" h% Y C4 \ 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和7 d( x# G# t4 |3 Q- b! s1 [( r) D
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。4 h! T- T. y. p, s
方式二:& c7 N3 W# a5 Y6 {) o/ ]" s* r6 S" ^
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:9 @$ e# O1 a6 k. x
SetTitleMatchMode RegEx) A) v! ]: x) |, _) r4 A( L6 W
return& C. H$ i, B9 D# g
; Stuff to do when Windows Explorer is open
. _4 W6 K+ b) _* G: k, g ;$ C7 U9 I' a) C4 p
#IfWinActive ahk_class ExploreWClass|CabinetWClass
1 Q4 _' x5 j& B* z7 g% Y ; open ‘cmd’ in the current directory
% U6 b2 Y/ t! {+ U6 f f ;
, J/ }! {/ S8 Q# D #c::" Y2 @ q* v) {- a z: p! h
OpenCmdInCurrent()' g' F @" L" P" D" L& K
return6 W1 x9 ]% J- v$ t0 i" G
#IfWinActive* \# r+ n3 a0 _. t% M2 B( o
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
2 q6 R( f5 E* u+ ~4 a, O( x9 c5 q ; Note: expecting to be run when the active window is Explorer.4 f; }1 k* x% ~0 G1 G$ x* L1 j6 w6 a
;' M3 v* E, \5 V- z, S: f
OpenCmdInCurrent()# L2 T, V8 o( Q2 W
{' X8 m' t% e4 E
; This is required to get the full path of the file from the address bar3 K1 O( h7 N2 D* F- T7 N
WinGetText, full_path, A* G/ |/ f$ ~3 v) A1 ], P9 r
; Split on newline (`n)
4 I& C' z% e% u0 |' A$ n/ k. v! D StringSplit, word_array, full_path, `n$ k3 W; ^$ M' v2 s4 Y
; Take the first element from the array& s- A0 n6 N- V: r C2 m# u* L
full_path = %word_array1%$ |# K5 ^; a* r( G" Y
; strip to bare address
4 `$ m! Z+ \5 z+ m. u full_path := RegExReplace(full_path, “地址: “, “”)
/ B8 P+ d9 x2 t% @$ k4 s ; Just in case – remove all carriage returns (`r)1 j) K9 x$ ^0 S$ U _, q; U. M
StringReplace, full_path, full_path, `r, , all( V) ~" f( o+ g/ @9 |" q+ N
IfInString full_path, \5 Z6 G, H- K0 _& z2 q( X
{2 X# ?; ^+ R% w/ u
Run, cmd /K cd /D “%full_path%”
6 t l R: Q. J( _: x2 Z2 \# P }
0 D* a% b" k( ~8 }8 z, M else
u `" E% k P. m9 _ {0 O( n" M# O K' [9 ~
Run, cmd /K cd /D “C:\ ”
+ o3 [1 s+ @9 C+ n0 C# Z }- Q8 d7 y& r8 T+ `
}
$ i! ?. b. a) u. C# e+ `5 w 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
% @& w% q# b9 A# A6 W" X5 N2 b 这段小代码肯能有两个你需要修改的地方) _8 B, K- k1 y K# i9 y, @
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
/ F& A8 ]7 V9 N# E& [9 _, B 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “+ D5 m! j A) k1 ?+ ^( f, }
|