此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
0 R4 x; m- X, ~. f9 g- ^8 [ 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
2 ]# u. B* P/ i* K3 D! n: @ 方式一:
- p4 r$ ^& f8 v3 t6 f& q 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
0 Y% M- `* O; S% j9 x; o* i 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
& W' l3 U( i& y4 A# D% ~ HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。: G B. B% M1 D5 ^# V4 q
方式二:4 P' v5 b& X0 U2 w3 ~& J
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
! T/ W0 ~, [5 t F1 R# E! B! L5 Y SetTitleMatchMode RegEx8 t( s% q0 W8 ^& F- N7 Q) b
return& q; m k3 t$ C
; Stuff to do when Windows Explorer is open
0 Q; W I5 |0 T3 b5 b% _ ;
8 W* _: W! P( U, Q2 O #IfWinActive ahk_class ExploreWClass|CabinetWClass
0 _7 G* S0 e3 y2 y3 @ ; open ‘cmd’ in the current directory: }9 w8 X- S* v
; A( k, ]! C# @! g
#c::/ S2 \: |# e# w4 C: A- i$ y) l
OpenCmdInCurrent()
) o& e# E: ]+ c) K9 j return" m" a, h% V8 z7 y' c' X( \4 A- m
#IfWinActive9 L9 `7 }2 d' P' y& w% N! g
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.: Q: Z5 N* w+ L2 K, N. [0 a1 C0 d' j
; Note: expecting to be run when the active window is Explorer.
2 I% b) z4 i' m9 c/ D" Z ;! q8 N5 c+ m; ?5 A
OpenCmdInCurrent()
9 n9 k/ H- i' l% }. Q8 _) g {
P0 `# K/ c2 P8 f/ r F! Y ; This is required to get the full path of the file from the address bar+ z4 s) Q( L+ m
WinGetText, full_path, A4 s" @! `7 Y$ J1 J
; Split on newline (`n)8 \" T* ]7 D1 @. h. {" w
StringSplit, word_array, full_path, `n
. r0 g' Z! ~' A% j0 m) M l ; Take the first element from the array" J( T+ j5 o7 x% j; g/ h& w! l5 c
full_path = %word_array1%
4 N3 o! q. S: r. m: } ; strip to bare address: Y" ?! W$ {6 N( q; H# A" j. ]
full_path := RegExReplace(full_path, “地址: “, “”): S& h& T% j" q# L
; Just in case – remove all carriage returns (`r)0 ]8 `: r, M/ m ?
StringReplace, full_path, full_path, `r, , all- B9 ?; B2 a% ], Z2 x$ f3 u9 K
IfInString full_path, \7 o2 Q# j+ H+ m8 J: t
{
( D. Z/ n% D- S9 \% i. E1 A+ E Run, cmd /K cd /D “%full_path%”. {+ d& A! l8 k4 Y: r [4 V
}
$ S& W, G; k1 C d( w# A else
' |) w" D- y7 H& B8 M7 }0 C {
" [' G+ K) r0 O2 E7 m Run, cmd /K cd /D “C:\ ”
' k8 V3 e. [8 E' H }8 ~" j U" G0 C2 M6 _: p
} ^2 L/ M4 x7 \, q
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。0 O- R' ~, F. U0 v! L. v
这段小代码肯能有两个你需要修改的地方
9 ^( V) \% }4 }( r+ G- Z 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
& T" H7 f3 d6 V6 E) I 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “2 n! \! {( Z& i: s) [9 @- s6 }
|