此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。, |9 H$ w* W" z
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。2 i- ?! r' b2 H. U! ]7 r$ j
方式一:$ {. S+ A( m* B
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
4 ~3 t( T- ]* V% h% X 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和# T/ \/ V0 p4 M/ \+ Q. i+ ]7 F! L
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
3 O, ? n1 |, Y$ W! r- y 方式二:
, C9 T3 a0 y( e* p- C! i 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
1 W- t1 U p2 ?/ Y SetTitleMatchMode RegEx
" X+ O5 @* Q5 Y2 c. [5 y- T3 z4 b4 P+ ] return
* R. e, V" [3 |& z. w5 L" z ; Stuff to do when Windows Explorer is open
5 I; h' J5 I' a+ r ;
8 b$ l1 f5 u3 f4 [$ s1 F- h #IfWinActive ahk_class ExploreWClass|CabinetWClass
" y5 F$ v1 s+ Y/ T( [) h0 J# M: q ; open ‘cmd’ in the current directory
+ b, i8 K( s. ` j- G ;( [3 l7 H1 x3 s9 T! N/ R. J1 Y
#c::/ m3 X. ^7 ~* w
OpenCmdInCurrent()
6 f. c l, H- m; I4 r4 B { return
3 b+ K& T; G* \8 `) u* \ #IfWinActive$ Q/ m! o& M' e+ e+ h% c- z, K
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.! m! b D, n9 _4 [% x
; Note: expecting to be run when the active window is Explorer.
6 U6 d- ]2 ^/ F) B ;* k" |0 q' C! j9 f7 i/ v% m
OpenCmdInCurrent()! m4 j7 N: M) ^( A$ _- T, |) ^
{5 s' a, o6 e7 k$ h$ a c: t- w
; This is required to get the full path of the file from the address bar
: {% r% H# \+ h WinGetText, full_path, A
3 _! R3 D9 S" f2 ] C ; Split on newline (`n)
9 y; R- L! D" T: F" o# o StringSplit, word_array, full_path, `n |# Y# S! p) Z# J
; Take the first element from the array( O! \% ^- s) z; G7 R' u/ w
full_path = %word_array1%
) ]. s* N2 B/ {# L' q1 ~& Q9 p( Y ; strip to bare address; ^! o) D" c( P7 ]& D1 g
full_path := RegExReplace(full_path, “地址: “, “”)8 z; u+ C# q: H/ j' N" I
; Just in case – remove all carriage returns (`r)6 U/ Z- T: @- a, ?
StringReplace, full_path, full_path, `r, , all
4 k# V& _# _" W6 S( _: g IfInString full_path, \3 [) k3 R, Y7 X, ^: j
{, f5 R& G0 z2 @, \- s
Run, cmd /K cd /D “%full_path%”5 E- f& a0 C* a4 Y, p5 _ q6 a* I, W
}6 S" Z! o9 I. h4 W3 v1 O1 m
else" ?. [' g) s4 h2 E+ ]. q! {
{
) H+ G4 A. P9 E2 N' _' C) h) b Run, cmd /K cd /D “C:\ ”* V7 R8 z& W$ ]6 k. C# \% t
}
' i8 i: T' x& u ]$ P }$ T1 O$ T: A( c; H8 l; M
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
9 S9 t' R8 ]6 |. V4 d 这段小代码肯能有两个你需要修改的地方0 p- u& i, ?7 J! D* L
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
} y& O3 v# E: D+ F 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
0 q0 f' ~( D/ a$ K9 B9 n |