此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
2 d1 N- d5 k; l" X2 F+ t+ U 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。1 I. h, {$ P2 u
方式一:
: v+ o& z, h6 |0 c2 M0 l5 w 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,7 s& [; P7 E/ g2 U+ N! }5 Y$ d( D7 |0 g
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
7 t& I8 L: b* ?. x' d8 }& y$ F HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
q$ P, x3 W1 ~& P2 k 方式二:
9 [( H0 F. o. P+ ~9 ?6 G0 v 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
2 i' {, R. k( A6 \ SetTitleMatchMode RegEx
" ?8 J; W( O9 {0 s$ n( { W# y return5 ]- ~) s+ K4 V2 I
; Stuff to do when Windows Explorer is open; _# a$ _' Q6 Q
;
8 N. w" D% i1 [ b( t2 l #IfWinActive ahk_class ExploreWClass|CabinetWClass
2 c# {0 c1 [2 O' g3 c ; open ‘cmd’ in the current directory( J& ^+ N0 s: O3 q4 |; N, Q
;; }$ e1 N4 p7 f- _
#c::7 H! ?& t) w+ b# g. q/ ]
OpenCmdInCurrent()
# x, X& g& h0 r+ m r return
9 K% |5 e) E; l' ` h; d #IfWinActive) [7 ?' Y8 H3 V4 ]: m3 L9 V/ ~
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
: V) s8 g, I3 [9 e4 Y( l K ; Note: expecting to be run when the active window is Explorer.3 a( u* h* t- K
;9 T' a% q9 Y' q- y8 d
OpenCmdInCurrent()
1 }: T# J8 K' c {. [4 J3 n. ~7 O) l3 D6 F( X
; This is required to get the full path of the file from the address bar1 g3 c) Q+ E; N' s: j7 X! M6 n
WinGetText, full_path, A8 E$ [; h3 p. y; L$ g
; Split on newline (`n) |6 d G/ f. E* Y% ]
StringSplit, word_array, full_path, `n
& {4 k4 ^1 R3 L7 }5 y0 x1 D- W# g ; Take the first element from the array, H: @; L% p% c! w7 `' Y
full_path = %word_array1%- R6 C$ @( Z3 f" R
; strip to bare address1 I, H/ c% w3 ]
full_path := RegExReplace(full_path, “地址: “, “”)
) q/ A. x/ ?1 T ; Just in case – remove all carriage returns (`r)$ \. s1 d( L( R ~$ r, v9 Y- Y
StringReplace, full_path, full_path, `r, , all
* O; l/ B8 |" h9 C* s! ? IfInString full_path, \
8 j$ E; I9 X a4 J8 P% m {
+ k6 g1 x2 F2 y2 Q Run, cmd /K cd /D “%full_path%”- s0 C* k6 j. Y% g2 Y
}
1 [ c( u8 }) ]8 {' g else$ @' m, r& n T+ Y& a% p8 Z$ D
{
! C2 r `& V7 q& c( N. D+ k% R7 { Run, cmd /K cd /D “C:\ ”
# T1 U- w: ]2 M6 I$ u2 s) } }
7 k/ V' ]7 p2 U9 Q9 N) ^3 e9 k# v }
( ^9 o6 Y7 x+ ~6 G* |- H; \8 B 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。7 b7 J- r8 {3 a- G, J
这段小代码肯能有两个你需要修改的地方
1 i; r9 C( q1 P 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
, b8 ^0 w2 a8 }9 K5 g 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
6 ]5 W- r- N, K4 L' b |