此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。 R1 N% R* T; y# G9 c8 g& `
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
8 H( ~4 {- e$ f4 b. ?% J( R3 ^# U 方式一:
6 @/ R' P+ m ^" c0 ` 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,) l+ P: E. L4 ?1 k
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和" I; e2 L4 Y, D( ]
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
6 O/ Z7 ~! b! z8 _ 方式二:7 d8 f5 ~4 g( a/ w, S
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
$ }" M* w; _, X2 r4 G& o8 _( y4 O/ @ SetTitleMatchMode RegEx1 f# z$ V, n6 G2 X: i" M$ w
return6 g) R) {7 L& P
; Stuff to do when Windows Explorer is open
/ L, \2 x# f9 A9 |3 g ;
( K% `( N% t# d$ S( \ f R #IfWinActive ahk_class ExploreWClass|CabinetWClass8 R" H n' C7 k+ U2 Y8 p* c, f
; open ‘cmd’ in the current directory% W/ }( i! l* l! W, e: c! e
;
' ]$ s! L9 \9 e6 F9 B #c::3 r# B7 J7 k' Y: d
OpenCmdInCurrent(). c( `# m$ X% y1 r
return
0 n9 A' S% q8 p6 t, I8 | #IfWinActive
+ o8 N2 C1 D/ ]% v# ^4 V { ; Opens the command shell ‘cmd’ in the directory browsed in Explorer., p9 Y6 c" q: k
; Note: expecting to be run when the active window is Explorer.3 I7 V3 v$ ~6 y/ ?; e+ j1 P
;) \9 e) k7 D, g: _! c
OpenCmdInCurrent()9 S6 G: V1 v* ]/ Z) G
{
p/ I0 V8 {! Z# Y$ f1 P ; This is required to get the full path of the file from the address bar
( E( F5 j* t! q) M+ C4 s) \ WinGetText, full_path, A) q" Y! l: ^7 h( ~; J# C7 p
; Split on newline (`n)
# h, k; O) g+ e" g, I StringSplit, word_array, full_path, `n
6 U/ i! G8 E K( O* T" S" U6 B* o ; Take the first element from the array
/ v8 T1 ?! O0 w* d, r full_path = %word_array1%3 G2 o# t; N3 r% B6 J' P
; strip to bare address9 f# |+ C7 y* K4 @* L a
full_path := RegExReplace(full_path, “地址: “, “”)
! j& m. `3 V$ ~$ X0 C" h" p9 o; w ; Just in case – remove all carriage returns (`r)1 l) o7 V0 ~( _& U( C, Z9 l
StringReplace, full_path, full_path, `r, , all
: u' H3 q0 A! E& e* b IfInString full_path, \0 q9 g1 i8 i4 m9 F3 [, ]! W
{. Z0 e6 f* I( ]+ l2 D9 `
Run, cmd /K cd /D “%full_path%”+ ^9 S; P* O2 W/ o2 G2 w
}) q2 F. I) a8 n9 M- v
else
! ^, t; {% T' P5 r8 `3 z% L. ~: @ {, c d) K: K# z3 k5 N) w
Run, cmd /K cd /D “C:\ ”
3 g* q: O' [% j4 s+ m }
1 r& J; Z, |5 o& I" [$ V9 m }) H6 |* x- R" M9 d- I
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
# ?9 R2 [3 g4 K& G2 V 这段小代码肯能有两个你需要修改的地方. r2 ?& Y% @ A8 M% h5 E4 b9 I
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
, b( Y4 {$ ^6 f0 \( ]* S5 ] 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
; | p8 ]# V" f# ^ |