此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
' s- J- j( x( q- {% n6 }5 \ 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。" i4 [ W. N9 j! M3 C2 x
方式一:9 ^9 S* @3 V3 r
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,7 l2 X2 Y1 x& a% a/ Q' c( `9 L
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和0 g1 }5 \; r- s& N- ^0 D4 E
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。8 R2 y9 z: H c! j
方式二:# o) m1 F Y1 L2 `
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
' \' f$ X* x5 ?1 w SetTitleMatchMode RegEx* f" m7 t; D; Y/ ?! ]7 n8 ~
return. @ }& D! ~" T4 Q9 K4 ~8 U
; Stuff to do when Windows Explorer is open) I3 h' u( F# m2 c. A( o
;1 p5 ]3 S4 s: P j9 Z" C) J
#IfWinActive ahk_class ExploreWClass|CabinetWClass
/ C( I0 j. {. @/ i; t9 _* N) P ; open ‘cmd’ in the current directory' Y1 m; o# H; }7 Q$ ~" r
;
/ K* e3 g G @% \# j8 G0 K1 T #c::
. s! e3 j k9 K$ g OpenCmdInCurrent()+ Y2 k. I$ ~; n$ u2 \
return
( K8 g# v. O4 f7 A7 b. O #IfWinActive0 h2 h& j0 Y: z: v) R: t: ]" X
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
- q2 R- g# x; R( H ; Note: expecting to be run when the active window is Explorer.
. k( _8 p1 m u u/ l5 B ;9 {) M' w F5 Q
OpenCmdInCurrent(). r& A! I4 c% W
{
6 z, l6 }5 g8 M ; This is required to get the full path of the file from the address bar
% U b! j: d$ j) S& V WinGetText, full_path, A0 V% C8 E' z! l, u: |% E
; Split on newline (`n)
+ e' j+ ?9 @/ n" h7 Y StringSplit, word_array, full_path, `n! p! _8 Q% P9 c& w" i0 Q x* P" M
; Take the first element from the array( i* Z. T0 c: O& b0 X: o1 ^
full_path = %word_array1% Y5 k; y4 X+ L: Y# F% e
; strip to bare address2 g$ w" F% t. M; P& f% K
full_path := RegExReplace(full_path, “地址: “, “”)# e2 a0 t* h/ Z* g
; Just in case – remove all carriage returns (`r)
* R( d' M9 H/ O0 v, h9 b StringReplace, full_path, full_path, `r, , all
+ D0 k2 l& L/ e' W IfInString full_path, \
8 q, h1 x% A; J: V/ @& M7 w% J ^6 d {4 I9 Y( E0 @. N
Run, cmd /K cd /D “%full_path%”% O! @- j* A2 l0 m3 r
}% y. m* }0 a: W& g% V" [2 d
else
9 n2 [9 }3 l! a7 `1 k- {# D {4 @* _4 o+ {& D n s
Run, cmd /K cd /D “C:\ ”
; ^: Q, D# k+ @ p$ ^# V }* f1 Q! ?9 A5 m! p% g$ s
}! r3 l$ d# Y+ W/ M
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。: R8 y! q( Y: P% W
这段小代码肯能有两个你需要修改的地方
' Z- q/ M. f# ], u9 y 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
0 |1 o* k9 G* r$ z 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
6 s' n& n1 k5 `9 M; A1 O% C |