此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
9 t* X. w' ?% ?2 ?6 D 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。7 b. ~5 n0 M8 [( j* ^6 J/ J; l
方式一:
7 g" ~8 A& |9 n 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
$ \4 Q; @% [) T1 y6 t0 M 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
) _7 u# W2 c( Y, X% h" {1 e& V HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
W% U3 F' i- @* M 方式二:4 L+ O k! k& P* Q k( j$ M: y$ `
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:( Z9 `' `4 P" @. A$ R. \
SetTitleMatchMode RegEx+ f( S2 v7 a& L8 x, c( T; l
return
3 }+ o% y( G! I. O0 M, A ; Stuff to do when Windows Explorer is open
+ ?9 ^% a9 `6 Q5 V1 ~# G2 I5 o# b( f ;
- N {- U+ G4 @) H: e #IfWinActive ahk_class ExploreWClass|CabinetWClass9 G6 J, k/ m: e: } {! H
; open ‘cmd’ in the current directory. E, i- E0 F# y! Y- u5 V, ~
;
) r( K8 }" T/ v #c::5 }5 I* B$ z) k. q7 b. f- D. u
OpenCmdInCurrent()9 `+ `6 ^2 X8 v; v7 C! |: y: o
return
$ _$ k$ s7 T- s, `( T* V& p4 z #IfWinActive
/ }: ], C: h- J ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.* o8 x! L0 |& n a
; Note: expecting to be run when the active window is Explorer.
+ P; A+ X3 [/ i$ i2 l; K% K# [- C ;
8 ^ j# U3 Y- P OpenCmdInCurrent()
/ B3 K6 k8 t; G! e7 P: s+ F& ` {: `4 I* S5 W% R* w* b
; This is required to get the full path of the file from the address bar( k6 p- P7 F+ l! R
WinGetText, full_path, A
/ s ~# f X% n1 z4 O9 s) ~' F ; Split on newline (`n)
! D* p$ U5 k+ f' E StringSplit, word_array, full_path, `n
4 J3 T/ H0 J1 g: y( ~4 U2 I ; Take the first element from the array! O1 S# T( K+ b. w# `3 q; ~. n% y( V) V
full_path = %word_array1%
3 K0 w; [' E) j; g( v ; strip to bare address! `8 Y) W! p2 u2 q3 z4 y, K6 r6 l
full_path := RegExReplace(full_path, “地址: “, “”)
9 W; F0 }1 V' y6 |# J) ^; h( r ; Just in case – remove all carriage returns (`r)
6 T l ]" ^+ g* F& K0 y StringReplace, full_path, full_path, `r, , all
4 T4 A7 d; n' D% \" W5 I3 E IfInString full_path, \; Z2 x" U! c# N5 U
{0 `: Z9 F& [* b7 ` {% G
Run, cmd /K cd /D “%full_path%”$ J( `1 \4 M& K' X2 q; F- q
}( W1 Q1 N$ e0 \: R
else5 x5 Y& L2 B1 L4 A# M3 K+ F
{
; l! a: X$ h' J* h) ^1 C/ W Run, cmd /K cd /D “C:\ ”% z+ @- G- [0 `3 u7 `( |
}" }( V2 U( }* z; ^6 D3 x& k' s3 ^
}* _" [1 n6 D0 a
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
7 O% S) o) j7 c. i, _1 E 这段小代码肯能有两个你需要修改的地方
: E8 E/ k1 s. P8 } 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
; m3 u8 j. s4 |% N' n% m 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “4 @$ e( @# E- Z+ w) {
|