此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。4 g( U. u2 ]) n- E7 P, l P
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。% B; {: F6 L& i% ^: A( d, ]- U) J/ ?
方式一:
; |! K3 k2 H# s5 p1 n: I6 K 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,3 C8 \/ T- C* w" d. E7 p
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和2 ?, {4 `. p+ \) v; x8 i5 m$ l
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
+ i- P' y% C$ s) n( ~ 方式二:: K* `0 _7 J* F( l6 D
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:6 z6 i! M# o. y5 p" a
SetTitleMatchMode RegEx
/ n4 C; j# j5 W0 r1 x4 @/ _ return
2 ~0 e. v* a- E1 s. A1 I8 @) ^ ; Stuff to do when Windows Explorer is open
) b% Y3 p+ q' S; N$ ?2 z1 u ;( O! E7 X1 j9 @4 v* [
#IfWinActive ahk_class ExploreWClass|CabinetWClass
( y( Z+ e7 u- I( h% @+ P ; open ‘cmd’ in the current directory
' X$ p% b/ U z ;; k8 I' d# ]$ T8 I% I
#c::
1 L" A+ y* F D { V0 l7 T; z OpenCmdInCurrent(), |3 \8 A# P6 P
return; g% F% P( b7 g0 b2 a. Z# E
#IfWinActive
8 n! e5 M# q$ L ; Opens the command shell ‘cmd’ in the directory browsed in Explorer./ T- N* r& [, n U( |. @4 ^. E
; Note: expecting to be run when the active window is Explorer.' Y: t& R4 s, W, l7 G* Z4 v9 Y
;9 |/ n# [: ^8 m, a
OpenCmdInCurrent()
: Q/ N9 r" }6 V {
2 B; d! E: U+ z0 s7 u0 c ; This is required to get the full path of the file from the address bar
7 [, q4 `5 A7 Z, y4 u% q WinGetText, full_path, A; y: U+ w+ q) m' |8 A* C
; Split on newline (`n); _& R, e- V6 C p* t. m8 o7 \% L- @
StringSplit, word_array, full_path, `n
D2 V- j+ ~! K- v3 a7 E# v+ ~ ; Take the first element from the array4 M. g6 |' ?0 l' h5 D" r8 e1 }
full_path = %word_array1%4 O8 y) d" f7 @: B$ w
; strip to bare address, {+ _6 g" j+ Z0 {& L
full_path := RegExReplace(full_path, “地址: “, “”)5 k% [1 T# a6 f; }# K1 N
; Just in case – remove all carriage returns (`r)- I h3 V" R8 K- P% v7 Q
StringReplace, full_path, full_path, `r, , all
8 N/ J- o% i9 U8 u) q6 }& c0 y, w IfInString full_path, \
5 y5 h; f4 u6 W3 M {$ J: O2 j: s7 i8 ?- _0 ?2 }
Run, cmd /K cd /D “%full_path%”% v' ^, ~" w$ A( A
}
9 e, Y* L ~0 y else) c0 f( Y8 n: r- Y2 A" v @
{
1 _7 O, X9 m3 v0 j Run, cmd /K cd /D “C:\ ”
6 X( m G. `- p1 f4 [2 E5 B! w$ U }" Z/ t- y0 f/ n
}7 C+ T) |! }8 l3 a! a
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。$ S9 }( @6 H- L$ {3 T7 a% w
这段小代码肯能有两个你需要修改的地方
+ h- {" d& C w x( C. m/ C$ S 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
0 L5 w6 Y* P3 E0 n! h3 S3 h6 G 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “1 f9 \0 ~5 m/ v
|