此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
& q3 v3 n( n( l7 ? 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。; d2 ~' n/ T' r/ a8 U5 Y
方式一:$ o* n- p m9 Q: [3 W
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
5 f( `/ a4 n6 A 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
7 i( W* T0 c" C HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
+ @7 N0 L) S8 @: R# u5 ~ 方式二:4 I1 i' j+ w* {6 T9 B& f
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
! t; i: G1 U5 N( w! h5 a* K SetTitleMatchMode RegEx
" i4 O& Y( P( h return
# w2 t. A* Q- G6 U ; Stuff to do when Windows Explorer is open
7 @) v* [& h3 r' f ;( n* Z8 @8 |' l+ @6 l
#IfWinActive ahk_class ExploreWClass|CabinetWClass
$ F& |3 @8 Y, J$ A/ S ; open ‘cmd’ in the current directory, K' s/ n! D, ~ |! h3 Y
;
/ p+ C+ h3 s* |5 g, J; M #c::
9 _6 D! L; r3 K* v B OpenCmdInCurrent()
) K0 P3 l! O4 X0 _1 m& g return9 j( a8 s1 T2 ^$ X
#IfWinActive: l4 q, D n/ u2 }" A
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
% \# y* l5 A9 H- s+ {- z ; Note: expecting to be run when the active window is Explorer.! P: v, @7 s5 H. E8 A
;2 l2 Q9 k, ^( |# U2 X( _. N
OpenCmdInCurrent()
# W! R8 M. Z5 S2 R5 m# ] {) w. C- u! S0 n: E% ^, H- r% L
; This is required to get the full path of the file from the address bar/ f' h5 \! C t: W/ ^4 s0 p5 I
WinGetText, full_path, A4 T- d( k! ^4 ^9 z
; Split on newline (`n)
& M7 U. @/ N3 s" @# N StringSplit, word_array, full_path, `n
1 F8 d% {# x' [! w2 a ; Take the first element from the array6 x. U. f: b% Q1 F/ c6 T
full_path = %word_array1%8 |7 X4 {' g& H# a B
; strip to bare address1 _/ Y, H+ C8 j' G% N/ m% q9 O6 h
full_path := RegExReplace(full_path, “地址: “, “”)
: ~% G! B6 k$ e5 Q, ?$ n ; Just in case – remove all carriage returns (`r)
$ b9 c& \ e3 N2 Q8 A' _+ c StringReplace, full_path, full_path, `r, , all- K S( B2 O8 D' @, C0 D. y7 ^& i% ]
IfInString full_path, \
# z9 \; n6 J% o. ^) `2 u {0 n) x1 d! ?$ U& a I' A7 Y4 u! H% i
Run, cmd /K cd /D “%full_path%”
4 K6 g9 [0 e1 {) K9 @3 `6 V }* W* ~+ }5 J8 R7 N E0 u' G8 W4 w
else5 J6 j' l9 y! l& o M
{! X% X' W* r+ [: I9 v5 R
Run, cmd /K cd /D “C:\ ”: {% e* J) n5 N# Q& [7 Q
}( u# H$ o& k$ I
}
1 D- I- }& X! v' J w; G- [, M 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
) ^0 t* z+ C. L( [+ ` t 这段小代码肯能有两个你需要修改的地方
2 S) u) y& ~( h0 B8 G: ] 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
" ]5 K- r% s5 d2 A9 i" u% O7 F- b$ A7 w 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
& R' i$ N% \( I! ?- n |