此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。# H4 d% A9 Z2 F" Q
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。' }$ D7 e z2 h4 r# g% C: A
方式一:* w* g/ y6 {8 y7 g) c3 h
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,# Q- Y2 s7 k7 t% b5 z7 I
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
) ]# P! [0 G1 \ HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
' j& i; m: V2 W! P9 A7 i4 G 方式二:
: D! j# a% T) R% \. \7 V 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:7 a5 Q$ _* ?- P5 r* b5 _
SetTitleMatchMode RegEx2 w5 J5 A$ F1 Q
return1 \' D3 B% S) I( w7 a
; Stuff to do when Windows Explorer is open. I* D4 R8 i8 }5 _$ t
;. S) O' X6 l0 J
#IfWinActive ahk_class ExploreWClass|CabinetWClass' k! r+ [3 }5 E
; open ‘cmd’ in the current directory0 n% j2 p4 _2 U0 x5 w8 o
;3 l. h, N& _8 h: b! m
#c::
/ i3 [9 X9 T! E# _ OpenCmdInCurrent()
5 S* r" c; v6 S return
0 @) p/ U! ?, _$ Y3 e+ P5 G) k #IfWinActive
/ W" H" ^% ~6 k1 g) p ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.' S0 f4 z, M( Q" C# p# z- z
; Note: expecting to be run when the active window is Explorer.
, @6 K+ u0 v1 n8 ^* O5 r, g0 C ;3 a6 K( z2 k- K$ h4 `. _
OpenCmdInCurrent()
& L e) T! X3 Q5 {* J {
+ G1 T& L. G% f- @0 r4 p ; This is required to get the full path of the file from the address bar
$ ^4 ?5 @5 {! a% R6 s' S0 { WinGetText, full_path, A
7 Y/ \' W5 I: w/ G ; Split on newline (`n)$ ~8 E, _+ S! X' v
StringSplit, word_array, full_path, `n
4 G8 V; p& ?8 m0 `% Y+ [ ; Take the first element from the array- p1 d( v9 W: \+ ^4 ?
full_path = %word_array1%: G$ E8 E9 _1 m# }
; strip to bare address E$ X9 H5 G( P8 d0 L) b
full_path := RegExReplace(full_path, “地址: “, “”)5 L% r# b8 n, H% Z$ X" }
; Just in case – remove all carriage returns (`r)2 U7 y e+ k+ i$ ~
StringReplace, full_path, full_path, `r, , all3 \5 c6 j4 U9 I e, @! b" |6 S
IfInString full_path, \1 z7 U* ?0 L/ U3 r- z
{
- P( f1 L$ n3 Q8 ?, y9 r; U2 a Run, cmd /K cd /D “%full_path%”/ @! U: f. s" D j e
}6 m* }( q9 j* M" S7 G# z" x
else
! U% p# O0 D1 u8 o. S0 \1 B7 R/ m6 T! j {
2 Y9 u2 P; v+ F: V$ y* b4 g& r Run, cmd /K cd /D “C:\ ”
8 O# ?7 i7 t. X; Z4 y# r8 s( b% ` }# j6 w: q* W: K
}6 ?+ k7 l4 g4 B6 D
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
3 W1 J% y5 w% C+ B 这段小代码肯能有两个你需要修改的地方
0 F, l; ~7 U1 Q( E 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
! p: l f: x5 Q 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
( I1 ~ A* K$ u5 |4 G- Q5 q |