此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
5 o; }+ i; G3 i( O. C9 j1 S9 I 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。: F, e8 }6 }# H& f A$ b
方式一:! q5 a" Y. b: C; ]% [! L: d
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,* m8 e# [' F! g# V. i
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
0 ^* m2 `" D+ U' t/ R4 `6 O* W HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
% E9 T' S% J' K7 b3 J6 o 方式二:
! ?' n- N4 q6 t: M( O5 R0 `- J0 o5 W 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:& G5 x5 r! h; |1 k7 }
SetTitleMatchMode RegEx
! ~) M4 t2 i8 a+ q return
/ Y+ z. h6 z2 S, K' U ; Stuff to do when Windows Explorer is open
9 j b, X% {' o, A0 C* V& @/ Y ;
4 e, w4 F8 t- |/ L0 M- K #IfWinActive ahk_class ExploreWClass|CabinetWClass1 _( P5 s1 Q9 M# ]( L
; open ‘cmd’ in the current directory4 P9 `% C% d }: |# c3 l) m
;1 R' b+ G4 e; }5 t" ^
#c::+ C/ R; [. W7 W4 w
OpenCmdInCurrent()0 n( C- p2 _9 ^
return. g9 g% b! ^; Y1 w
#IfWinActive
& m b8 I: u3 B' l) w ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.5 w+ F2 \/ y3 o3 o2 c. E
; Note: expecting to be run when the active window is Explorer.
5 f9 t# ]! T0 J2 C ;$ m7 O- W( X9 Y9 U+ f8 l
OpenCmdInCurrent()
! g9 ~1 H" C+ D {
/ w) B$ p) j/ u ; This is required to get the full path of the file from the address bar
4 A$ b/ Z5 I' B WinGetText, full_path, A
& K- Z, E; P3 H) _9 C8 e ; Split on newline (`n)
6 F6 ?: j: }1 i6 k, C+ X$ q l StringSplit, word_array, full_path, `n
: }3 v1 A! i" \& p5 Q* x# p5 D& Z- k ; Take the first element from the array* i2 ~7 w/ b4 R, l) J0 d$ X T0 m
full_path = %word_array1%# `1 G" y- m% \
; strip to bare address
2 H1 n A; A7 V J. [ full_path := RegExReplace(full_path, “地址: “, “”)
* X+ ?7 j8 m: n% ] z& I ; Just in case – remove all carriage returns (`r)/ d8 V) Y0 P" ^# ?
StringReplace, full_path, full_path, `r, , all& P: b9 Q; s! h/ y5 x+ w9 \6 Z( b
IfInString full_path, \7 Y/ x: ^2 m/ b0 M9 B
{8 y" D+ s0 h) Q7 H, S
Run, cmd /K cd /D “%full_path%”
: H9 m2 c% D+ w& x }8 T9 R2 f; d% }9 c4 X
else N* |$ m. o G1 |1 [
{
3 W4 Y0 c D, H Run, cmd /K cd /D “C:\ ”
9 M* H$ _# j8 D. V2 l }
+ h" V6 W4 p( { }4 w1 b ~6 E+ Q- t& O. \
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。9 f0 o8 X! B, S( k) ?1 j9 n
这段小代码肯能有两个你需要修改的地方. v- f: d8 J) }5 y/ L
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
6 M# i# v0 N! w& ] 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
2 b# |& h' |& H, i- ?/ a: c1 z Y |