此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
: m- ]7 K5 C7 N 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。6 T1 ~) S4 `; b, h3 o2 F
方式一:
+ a B$ A4 H& K3 Z* G 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
7 _: f4 y2 E9 P- D& v! T" q, U 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
8 n3 k0 a- G8 L/ z# P5 d" R HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。, e. J! O& |; ~6 H( a! a& F0 N( b9 j1 q
方式二:
: }* _$ p: A7 z" I6 p 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:7 Y7 R6 U* g' |$ f. b4 t
SetTitleMatchMode RegEx. n& H2 J) G9 ~( O; ?+ u; y
return; r: V+ \8 K* S1 X- _( F# v. @
; Stuff to do when Windows Explorer is open
6 I& }( \8 {/ B2 v- ~ M ;
/ r9 {/ v3 D; P5 i% z0 j #IfWinActive ahk_class ExploreWClass|CabinetWClass$ t) Z9 i9 x" {, B
; open ‘cmd’ in the current directory7 F3 r8 D& m k$ J A
;4 W* t+ _! }- c5 ^* X* F% _
#c::
4 y/ f, V" m* S& e5 E OpenCmdInCurrent()
$ v. o' o2 ]4 S% g ~ return* I6 d9 x; [0 h0 {5 c: N1 Q, s7 Q
#IfWinActive
: p2 a: Y; Z2 k5 z' ^* v5 T+ k( d ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
7 _) M/ Y1 f4 Q3 j& _ ; Note: expecting to be run when the active window is Explorer.
; o& w$ t% O* U; S- { ;8 l% W6 w. j7 I, C
OpenCmdInCurrent()0 n( {$ I' f2 ^8 j1 T$ ?) M
{0 ?3 q4 _5 N S- l2 f9 _) g
; This is required to get the full path of the file from the address bar% g! J+ n; I2 }; F
WinGetText, full_path, A8 l7 u2 Y; Y0 C% @( J/ A9 o3 b" l" Q
; Split on newline (`n)
; [: G# g% J% b0 J StringSplit, word_array, full_path, `n3 K: t! E ~( ~( j$ [) [: G$ t
; Take the first element from the array1 S; O& O0 O' A3 f# q5 O- h/ Z
full_path = %word_array1%
8 P$ V, `0 z: \ ; strip to bare address( x7 N# s' u- q
full_path := RegExReplace(full_path, “地址: “, “”)+ t. l* z& w9 v! d3 z, b9 k
; Just in case – remove all carriage returns (`r)
0 m9 B) C- S% E StringReplace, full_path, full_path, `r, , all* J, ~4 A& c% O" Z0 |
IfInString full_path, \6 P: E) N+ @6 ~# C) [8 b, W; h
{5 l& v/ {4 Q9 Y5 j% ^
Run, cmd /K cd /D “%full_path%”0 V$ L% }1 r& @
}) f: \' s4 B, Q4 T
else" r4 e6 N* g; H: p" }$ O, ?' e$ O2 }
{2 t. s" _. a7 G9 k* H1 ~' b
Run, cmd /K cd /D “C:\ ”" r+ I0 |6 d2 Z
}9 ]) d, v7 P5 l4 f0 v
}
6 N- r+ A/ j" \0 K. U/ [, O) r9 b3 N 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。1 Y4 \7 F7 M) z% P) v( U9 g/ q @, a
这段小代码肯能有两个你需要修改的地方
2 T7 H9 Q2 V- A% s" q/ D 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
0 z- D b8 a8 x! C, ^ 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “5 ~" Z. m2 h. t9 t$ c
|