此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。6 A+ { U8 O# D) k( S' F' P
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。& e5 F$ p2 J) p4 }" O) }& X, z3 \
方式一:
4 {& Y+ V4 y8 {4 m4 ~. R 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
7 I. ?3 @* o T& `+ x 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和9 D' m! z% V- M$ q+ A
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。9 M0 q7 r: ^, b p1 |1 H# v2 @
方式二:& m/ d! G; f r, }2 L9 A
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
8 j" z f, A1 p6 d1 v5 a SetTitleMatchMode RegEx2 K, }( p# C9 ^2 F7 M8 f
return
, a% p8 x: c* \4 E3 J1 P s ; Stuff to do when Windows Explorer is open8 a# h2 p; q4 ~# T2 U) n
;/ d" Y) R P; T( ]
#IfWinActive ahk_class ExploreWClass|CabinetWClass6 `( _3 m! R- a* ]/ l
; open ‘cmd’ in the current directory9 R9 `: W, q6 v+ E. o1 s7 K6 z2 b4 S
;
0 E" t3 g+ M7 n& [1 _+ \2 k: O #c::
+ H: {: e6 o* K) d; q OpenCmdInCurrent() w+ n7 A1 | E
return
+ H: [9 a5 V4 n j1 m #IfWinActive/ k4 X1 V* d8 \9 y" }
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
9 z2 D% T( t) a7 v2 a x0 c ; Note: expecting to be run when the active window is Explorer.# o* D% c G0 u9 S+ W" P, o
;+ _5 _) a! ^2 T1 r b5 C1 E- v9 e
OpenCmdInCurrent()- P- D3 \' T: \- V
{
% [; Z8 O9 c# ?- o5 T, B ; This is required to get the full path of the file from the address bar
, h& a. B' Y" b4 Z WinGetText, full_path, A* Q" h& y6 \9 U' p) v8 f
; Split on newline (`n)
8 B8 ^2 v( d- i. W StringSplit, word_array, full_path, `n
/ S5 o' `. P! [ ; Take the first element from the array
; J) m. V9 R4 ^+ U; G full_path = %word_array1%
4 |9 t9 T% Y/ r ; strip to bare address( u: [# _9 `. @1 c, Z6 l( ~& \6 J
full_path := RegExReplace(full_path, “地址: “, “”)- J; t' e& ~/ m3 x/ y+ S6 Y, j
; Just in case – remove all carriage returns (`r)
. A+ @! m3 H; Z, Q; `6 ^ StringReplace, full_path, full_path, `r, , all! l7 C( X% z" d9 j! Q$ U1 f
IfInString full_path, \" s" X6 V& q- r# i' J' p5 |
{: O% X5 z6 t: X. e0 ^8 @
Run, cmd /K cd /D “%full_path%”# U D6 B0 ]" T) B
}' h. y, Y# w5 Z
else7 q6 X+ U0 T2 k5 i _
{) }/ `( q- p" I( ]7 s
Run, cmd /K cd /D “C:\ ”
" j" H& t( b! q5 n }9 O3 g8 o. M) q! c% w( J$ u; s4 R( s
}
* r2 J q" p& G7 s. D9 i" a' ` 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。$ J0 |2 g( A5 i2 p9 o, S
这段小代码肯能有两个你需要修改的地方
) o8 J+ b( L3 ^# f* a 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
2 v: F; m4 _9 } 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
4 [1 q$ ]( H) h, h, _3 r' F |