此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
+ Y w" Z( x& u4 j/ o4 }3 Q- i. { 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。2 P0 ?& J( Q- a2 E7 }1 U
方式一:
* t5 Y5 Z8 e8 }9 j- Z 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,/ D" A+ n1 |4 J5 t0 q
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
A! d) G9 m2 [& ~5 F HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。$ t# A" n+ e2 ~
方式二:. Z. g' R4 l0 U Y- ~( c
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
( s8 ~) O" L1 J4 u SetTitleMatchMode RegEx5 f$ u' b5 L U; V- \
return' I2 c" y. M' k( g
; Stuff to do when Windows Explorer is open
+ {+ J$ H8 e7 |, r% m8 P ;( T' W+ X1 u2 n% k
#IfWinActive ahk_class ExploreWClass|CabinetWClass
2 Y0 C' r: K2 I) H' H8 A# M ; open ‘cmd’ in the current directory: Q' l; n/ W$ K0 i
;
. \6 b) X0 X5 C6 i/ E! W! X) y #c::
0 V# n2 @+ ~, n2 C, K7 C OpenCmdInCurrent()3 j* n; J, e! z' o& \
return
& a7 e& b5 o- @' J #IfWinActive
; W" ~ Y% }8 ]1 y; E- a5 Z. O( q ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
: |" X7 V0 h8 L1 ^! ~/ i! { ; Note: expecting to be run when the active window is Explorer.
+ x/ ^- g8 i, b" q3 l; t ;
+ T8 w; q6 r, n7 Z" N8 L OpenCmdInCurrent()" r# D1 t) l- G/ e$ f) u; O
{, s4 M) }; }* S+ t- {& ]
; This is required to get the full path of the file from the address bar0 u3 r8 x J; Z! L7 P {8 R0 s
WinGetText, full_path, A3 y* {% F- @4 y6 N
; Split on newline (`n)' q' D+ d+ S: m4 x
StringSplit, word_array, full_path, `n. p' }+ d5 @$ J2 k4 I: Z8 I7 Y
; Take the first element from the array
- Q& j( A2 a3 ~% ? full_path = %word_array1%
3 u( m% B+ q: s; l5 r3 J7 R+ x5 g ; strip to bare address
7 _. S$ T! M5 ?' f/ a1 i full_path := RegExReplace(full_path, “地址: “, “”)' W) q" Y* z& J' i* u5 o4 ]
; Just in case – remove all carriage returns (`r)- r' g2 O+ F s+ x9 ^. D! F; w) w
StringReplace, full_path, full_path, `r, , all& i% ]+ U+ ~3 w3 t% u5 ^6 S0 ~
IfInString full_path, \4 S! H2 n: P) J5 F5 l
{
) M) V+ m: a7 w: B Run, cmd /K cd /D “%full_path%”
/ z5 q2 G& ]7 S( P# K }( [$ |' |$ U u) l8 f' h
else% [$ k& f& ~! z7 O' Q* J9 a
{$ `; l* K5 H9 S' O: U+ u8 }' ^
Run, cmd /K cd /D “C:\ ”
8 r7 s7 p* Z7 n* ~+ p5 P* t, l! @ }
5 @6 L4 w; M$ A- g+ F0 I& w }% K( x' |! f/ l% @9 E s
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
+ E& r" Q0 c6 _) V4 X( i- P: H' A# m 这段小代码肯能有两个你需要修改的地方* c4 a5 K& H, Y: F$ y
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
% q/ C) }& S: [- A* _% y 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “; E6 A, {% T, K- A
|