此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。) Z x) ?; z# A. t r5 h, B& t" @
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。1 B1 P: y( t9 g* j( D) V6 _
方式一:
/ W9 H( d- y* B [/ C- E& ? 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,5 {+ M1 d. s' B
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和4 E" ~* |/ o5 Z; N7 o
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。" W1 ]. s) B- y U+ J
方式二:. u7 f! c x0 l! ~; j
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:- R0 H! n8 z e4 h, q
SetTitleMatchMode RegEx
+ f/ ?5 G. B7 C& @ return
3 Y% u7 k! z0 E, n5 w' R0 i ; Stuff to do when Windows Explorer is open
6 X3 z, L8 k& \$ v$ s2 j2 Y5 W ;) P$ k1 ]1 G1 U
#IfWinActive ahk_class ExploreWClass|CabinetWClass
! |2 M6 u& W6 I, z: _ ; open ‘cmd’ in the current directory
% G: n6 P% i' g3 c6 A- r ;
+ I: I( l. }: \ #c::
' _: s( f- h+ J% z9 y7 z4 U OpenCmdInCurrent()
9 L6 O% j8 w, @$ w/ \" z return! Y" K& Y! ^: L- a. \$ ]
#IfWinActive* D6 `, o+ W6 z( u
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.9 t! [7 U# N7 H, [- U9 Y6 r! g5 a
; Note: expecting to be run when the active window is Explorer.
, w0 U1 o' J, Y0 z+ Y; @ g* V ;+ t/ ~5 u7 J( X
OpenCmdInCurrent(), l: \5 \7 a( I7 ~1 b, [- R
{! i: b: N2 _! @2 W
; This is required to get the full path of the file from the address bar: K' f2 ]0 X5 Q, @* K. o6 z
WinGetText, full_path, A
- m6 T8 w/ w+ _9 f4 O4 w6 y, m/ @, H ; Split on newline (`n)
0 p8 _: R- c+ j- `" `6 H StringSplit, word_array, full_path, `n
( e& j {: @7 b1 t3 J9 s# N0 S ; Take the first element from the array
- Y; r2 x7 I; Y9 G full_path = %word_array1%8 y" R0 q4 S* j( b, C0 y
; strip to bare address
6 R$ V+ \+ H) j( w: z) I) B e# F full_path := RegExReplace(full_path, “地址: “, “”)
M4 `# \3 f" ] ; Just in case – remove all carriage returns (`r)# e& g( ]& H# F. K( p2 H5 i
StringReplace, full_path, full_path, `r, , all
% U/ u& q( K$ p/ E! ]2 ^ IfInString full_path, \
, c+ L2 F; F8 @) E9 J8 F) h5 G {0 y' x* c6 Z8 w3 o' p$ Y. B9 K7 D2 p! \0 P
Run, cmd /K cd /D “%full_path%”
0 p! O$ l! a( E- W! P9 v. ?9 I }3 u5 Q- X. X0 P' N6 D
else
. g# W. W1 u) s* H5 Y7 \. ^4 h {! z% `+ {( z& O
Run, cmd /K cd /D “C:\ ”8 _4 E. H8 h" t) H5 ^0 ?# l! k0 e; z
}. [4 g8 [ h0 q0 Y: e; \3 t; z/ d
}+ o9 H+ U5 ]1 ^# e# d3 O
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
# l, i3 ]1 |" K! u 这段小代码肯能有两个你需要修改的地方& G0 J2 C# @) W
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
. W* F- e- Z: Y# \6 I F9 } 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “! ~9 i, _$ j h' y
|