此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。" Y. G" ~% q# p* W
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。3 r- o5 Y+ {: Z) }, G
方式一: g. ]7 Y. H. `; }4 j$ V
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,( N( ?. N) e1 ^7 Q/ X. W9 D, Y8 G
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和: z7 J$ z: k. G! p( b
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
! U# ~8 O& d" x% M 方式二:" Y2 U" Q+ f& ?3 g2 f$ w
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
- t( F5 R+ k) |; @+ g4 R6 l9 A" X SetTitleMatchMode RegEx
- f6 g+ f c/ K q& p return' _3 D+ l+ Q; r" `( z. r1 z
; Stuff to do when Windows Explorer is open
" \/ e* n- u( l' V" ]% ? ;# j+ {! F; d) Q9 |* P
#IfWinActive ahk_class ExploreWClass|CabinetWClass
* j( p6 Z1 l1 q ; open ‘cmd’ in the current directory
3 b/ G% z, e( R1 b0 | ;
I9 f6 [! x# d6 V+ {/ z+ Q #c::) j" S* ~! W0 Z; R ?
OpenCmdInCurrent()
" z- f2 v0 m: E/ G+ w" B return9 w, \- h! u3 {' L% E! Z) F
#IfWinActive3 @) Z: C7 f5 V- f1 y! s/ F
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
4 R# [% w3 l6 P7 j4 T/ Y ; Note: expecting to be run when the active window is Explorer.. X+ k. P3 U4 l1 `9 {
;
, b N7 U* ^3 Z# p/ C8 K8 u OpenCmdInCurrent(): f- q9 L3 x |+ G
{$ f- @: D- ^/ ~+ i) X' v
; This is required to get the full path of the file from the address bar
3 M+ n4 R8 h1 i" _; y- V$ K WinGetText, full_path, A
* w/ |9 ^5 K. M: c/ E2 T1 ?5 Y" P ; Split on newline (`n)+ o. R: b! P0 c7 }4 a
StringSplit, word_array, full_path, `n1 q) d: ?' W* x* h+ j8 R7 u
; Take the first element from the array
' i; F3 v6 M2 G; j2 c* } full_path = %word_array1%
8 m8 s) q+ H' ^8 U& h' h ; strip to bare address. A, K, ^; t' \) a1 _
full_path := RegExReplace(full_path, “地址: “, “”)
2 h4 q( `9 s6 ]7 T8 o ; Just in case – remove all carriage returns (`r)
3 q" |% m$ }8 C StringReplace, full_path, full_path, `r, , all
& a1 j# c% V; Q4 p: R' f! e# z O; f IfInString full_path, \
# t; N" h: O- z7 F7 \ {; A& D% f9 i6 H- a( i0 d
Run, cmd /K cd /D “%full_path%”
: k u9 G; j! s, T5 n0 C7 a }; u* q' u3 P6 F7 T' m" i1 p7 H
else
6 [- b* L5 D! d7 b1 J+ j2 p" R {
9 Q- T8 T6 O4 s+ a. x Run, cmd /K cd /D “C:\ ”( t' u G$ e3 b$ R3 m7 _' @" v
}
2 H, A5 {5 V4 R7 g, z: V @ }
2 u8 M0 u' i2 m2 e. ^& ?* S- x 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。5 O! m. W7 x, C ~) F$ u8 i$ C0 o/ u
这段小代码肯能有两个你需要修改的地方
3 Q- c, i5 g7 i- o p% j+ _- f 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
; y9 ]' L# ^1 l# ^! O 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “) M, F V* S X) R- i. P0 g
|