此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
, q8 n7 M4 ?0 s" r6 e) U# U 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。0 D, y, Q* f1 c5 o, W
方式一: B! e$ Q5 R/ ?$ I
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
4 b H- z4 T( q8 A 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
& b, _) Z% b# Q" T1 W- l HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
0 ^1 N3 R4 }8 l; D e# a! ^ 方式二:0 L1 `' ?- R( w
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
* m/ w+ E5 d/ q: f: a5 l7 D B3 w( U SetTitleMatchMode RegEx
0 N0 e) @6 r* P8 R8 ` return
. N& [: F9 s: Y* {+ K& _ ; Stuff to do when Windows Explorer is open
) x7 H: z* r1 b0 [ |2 T2 W ;
* M& ^; b+ b- s& F) Z! }& \ #IfWinActive ahk_class ExploreWClass|CabinetWClass6 q1 ^2 \1 T6 A' S
; open ‘cmd’ in the current directory: s. G, I& Z6 I t+ C
;7 j0 F# }- F/ ~: f5 ~4 N4 A( @) s
#c::
% O) u. u$ d8 L2 i; i OpenCmdInCurrent()
* c* b) }/ L% V# k return# Y3 l2 r5 S3 ?; I A* P
#IfWinActive7 a1 ]+ x( M- U; y/ Y7 [
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.( x; r' F, |7 E! o& Q* D- w
; Note: expecting to be run when the active window is Explorer./ i" C, c% X3 J4 G
;
1 r9 z% }. X4 ~" I+ K OpenCmdInCurrent()
) |& K2 }7 y4 s5 c) o {
9 {8 `! b3 g& z( A& C ; This is required to get the full path of the file from the address bar, H& W( b- u- D: V+ d3 Q1 U
WinGetText, full_path, A* { f1 B* N% g% Y* {$ v% j
; Split on newline (`n). L3 A/ R/ T7 ~" z
StringSplit, word_array, full_path, `n- H: F' h( C* O' f$ h; K8 h+ {' q
; Take the first element from the array9 Y" W. X0 c+ @) X+ m9 i
full_path = %word_array1%' t3 E8 c C" j; f ^: F& K+ A
; strip to bare address
; s: C6 Q9 F- v full_path := RegExReplace(full_path, “地址: “, “”)! _% _8 w; e, X0 n* s
; Just in case – remove all carriage returns (`r)& q9 C, O: a/ q7 G
StringReplace, full_path, full_path, `r, , all% }2 p" r7 X+ b3 n% c9 h. F M
IfInString full_path, \
5 N8 ~9 J* r# S6 C1 b {
$ S* s' j) a* ?! i$ k9 y Run, cmd /K cd /D “%full_path%”' }. \' |, d8 O* O! Y" {: E
}
3 J/ I' G7 ^5 ~% B8 ^. v else# P9 A$ `" d" a0 K
{
8 f# R" q4 r3 z Run, cmd /K cd /D “C:\ ” n: \4 B5 X& r# d% ^: d5 \1 ~1 R2 J
}8 E+ D% _3 B3 F1 E
}
( H6 _; k% Q: G; u" F 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。9 o3 y! O# s9 @! V- k- i) T
这段小代码肯能有两个你需要修改的地方
& u4 J: Y& H" T+ P8 ] F 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键0 T- X+ o" s- O) ^7 {
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
1 k8 p( u. i# C+ N6 |$ { |