此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。- C0 d+ l& [# q Z# D5 |
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。- r/ d- O, A0 G& t/ y' V
方式一:% b. H' K3 @' C0 L; |+ z- C5 i2 g
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,1 Z& _0 k. m' ^% N8 }
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和- Y: c0 L. C; }
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
3 T! R" L4 s7 R( V: u* y# Z- b 方式二:9 N# q. `" B2 N4 d
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:7 X' D6 K. L* S" ^5 b
SetTitleMatchMode RegEx7 T5 B7 C% S$ |/ j2 m( X! U& r* p
return
. u) Z' D# R4 I4 B, q$ L; ~7 Z ; Stuff to do when Windows Explorer is open e" {8 y3 O: w, n" w0 g* j
;
: w9 G c9 N- Q3 i2 ` #IfWinActive ahk_class ExploreWClass|CabinetWClass. g0 T$ W% G& ?, }6 v) D6 y
; open ‘cmd’ in the current directory0 M7 P3 C) ~) Z: [! O
;- k9 D5 s9 }8 A+ _! _: X# m' a$ ?" N
#c::$ H, Z% p% C U+ G+ B
OpenCmdInCurrent()8 V, B0 @9 j" r0 l
return
8 @# ]5 t* }9 l6 J4 R: o' {! Z #IfWinActive
2 T' S2 D; ]: G5 x# n ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
( V1 s1 B. o. T" b( i* m0 ^* M) ] ; Note: expecting to be run when the active window is Explorer.$ w6 ^ v! d6 R# x
;
7 P, `4 ^: O3 g0 M$ v4 ] OpenCmdInCurrent(); q4 p ~6 H9 Y
{
7 d7 d& V% T+ H s ; This is required to get the full path of the file from the address bar% E0 y4 u$ c, m$ b" q3 T
WinGetText, full_path, A
: O$ R$ B" v/ \" T ; Split on newline (`n)
; M5 H- J. ^ Y2 z StringSplit, word_array, full_path, `n
$ x1 I1 u( i% Y: m ; Take the first element from the array6 I2 |( C: |" u& g
full_path = %word_array1%. Y& e* \4 }9 { d3 G1 @$ i$ K/ C
; strip to bare address- ^# C0 _( t6 V3 c) f9 j) e2 I
full_path := RegExReplace(full_path, “地址: “, “”)
: z6 K* R' Z" m7 A& W& \ ; Just in case – remove all carriage returns (`r)- x7 }. a/ v# Q
StringReplace, full_path, full_path, `r, , all
) Z9 ]& ^# t. Q7 J1 {" N% w IfInString full_path, \/ o9 K4 i3 I" D4 m% ?
{3 ]6 _1 v3 ` b" S7 u
Run, cmd /K cd /D “%full_path%”+ z5 |/ Y) I% k2 O4 V# |8 P2 a0 O: h
}& y1 S( X1 M! J% e
else( Q/ c, K7 E0 g$ R7 A
{
) C; C/ b& D1 `! O) u2 q) I1 R Y Run, cmd /K cd /D “C:\ ”$ U( I; A) V; J6 m# L3 \
} u. q# H5 U$ Z) z( T; b
}
& T4 a) W7 }' \$ w" L 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。, j; M/ P" S8 u/ Q
这段小代码肯能有两个你需要修改的地方) j1 f1 i! ~/ w- |) P) x: M
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
. p$ m/ P1 |) \9 O4 R. D- t- w6 H 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “1 V2 h/ F' R8 Q/ L" `) u: A- g4 m
|