此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
5 J$ K$ T3 f6 y- k 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
0 q+ `+ k2 Z' J* U 方式一:6 e' ^" p; m7 |( C
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
( q. R' o+ I$ {/ ^ ?7 Z W( r4 O: [( P 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和* ?. E6 K3 \3 N. W$ ^9 z2 m7 k
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
) o) B O& q0 x5 o; S7 N" ?! ?* Q; b 方式二:
: t; S2 o' B8 d' J 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:0 H/ z( m! G3 b( Y9 E9 E4 t1 d
SetTitleMatchMode RegEx
( f4 v# T k; i& a0 a return
$ x R( f2 G9 z! H4 ]3 N ; Stuff to do when Windows Explorer is open
9 V: u! N4 d! ], p ;
/ j( b; ]" {. z4 v1 l+ G& n #IfWinActive ahk_class ExploreWClass|CabinetWClass g0 L& Q6 b* t3 U: N+ T( ~! X
; open ‘cmd’ in the current directory+ k% l. Q( I# W% K% t
;
* F9 P T; E! V #c::
) L( E. X; c1 Q4 l OpenCmdInCurrent()
% n9 s: t0 ^, k+ d) E return# Z+ S v" A( w
#IfWinActive
) {7 E( b9 l2 b! \ ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.4 ~& v8 Q/ w! M" W) R! F
; Note: expecting to be run when the active window is Explorer.( |8 ]% G, M8 w$ q, ?* I; S3 I
;
W- E: b% }$ ~, `+ P+ ^ D7 Y; o OpenCmdInCurrent()# \" O, ]4 @2 O5 i& [. R! j
{' t# e* m) _# H6 F- N% i
; This is required to get the full path of the file from the address bar3 s( O. o- o( r) M" n5 ^% E) c+ x
WinGetText, full_path, A% ^" `# A2 U" K5 r1 x
; Split on newline (`n)7 B8 I' J/ v4 O# B: |
StringSplit, word_array, full_path, `n% j3 ~2 e4 M' h$ C2 [7 H8 R6 G. U
; Take the first element from the array
# v' M# X- J' u' d full_path = %word_array1%
% N6 i. ~& x- Q2 v4 Q0 P3 O# v+ d, L ; strip to bare address+ U3 O* U1 @7 J" m' p! K
full_path := RegExReplace(full_path, “地址: “, “”)6 Y& R: P# \, q/ N# y8 I
; Just in case – remove all carriage returns (`r)
! J" a8 i" v9 t; o; A. `/ r StringReplace, full_path, full_path, `r, , all4 D1 M/ i5 U, v
IfInString full_path, \6 J4 A. e; Z' h4 |, A
{
3 U/ L. a8 u" o; p Run, cmd /K cd /D “%full_path%”
+ |" _. |+ L$ I* F( c }" {. M0 L4 I E4 ~% @/ U
else: ^# \9 g7 S4 |3 i3 }
{! j0 Q; x N" X) d3 n
Run, cmd /K cd /D “C:\ ”
1 m3 ?& N9 A+ }% F& O }2 d/ l! A4 R" J, a; [* H2 J4 w9 o
}
" L! O9 o4 P }3 A6 E( L 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
9 I8 O% | J8 [+ H* c 这段小代码肯能有两个你需要修改的地方
$ Y' A1 r4 T2 M0 a# n 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
" d# n" ?- g# \, [! I 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “' w$ q, n+ t1 r' ^2 C, C+ d
|