此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。7 N) `- W/ V" n- R+ E8 Y+ \8 f
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。6 J( _# x' [3 q0 z+ s
方式一: I+ a: S- d$ M1 Z/ f
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
2 E) R- [$ f( G5 } 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和2 G* \: A+ U' b
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
8 J" W9 M- @9 o- R( P" [ 方式二:
) {2 ?4 g) ?% k8 o) n- q7 I 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
+ N6 [8 a" r; k3 A5 J SetTitleMatchMode RegEx
' I' i( n7 M0 Y% J T! j return
1 X- A7 T. t4 P4 X$ [% T1 F3 ]8 S ; Stuff to do when Windows Explorer is open
/ {: T5 x3 w# c! x: t+ D+ `9 v ;
6 |$ R+ v0 m0 s #IfWinActive ahk_class ExploreWClass|CabinetWClass; l: {' _4 h) e8 A) n7 ]. |
; open ‘cmd’ in the current directory6 S8 a5 e& ^* p( ?
;
( O: L* w' S5 R% H3 L# W' x #c::( _, Z7 F5 L; i
OpenCmdInCurrent()/ J3 `6 r+ p9 `
return1 P# X* U: p8 R- Y
#IfWinActive$ ?: b* N" A6 j3 U- o- G1 N
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.' w, ]; a- q# T: f
; Note: expecting to be run when the active window is Explorer.6 p; z1 }+ B+ w& @) A6 h
;4 H* b( d; z% p, y
OpenCmdInCurrent()3 Z) G0 l! m R: B; ]# j2 Z
{
7 A$ I; r3 I8 l& P' P! M, D- S ; This is required to get the full path of the file from the address bar, M0 X& R7 s4 Y0 @$ Q$ I2 b' ~
WinGetText, full_path, A: o! c* i" G& g( l( g: ]
; Split on newline (`n)
4 |% P0 c5 @/ C# y' B StringSplit, word_array, full_path, `n" w9 R! v, T& y: O0 W* a
; Take the first element from the array
7 f. N d" m; B. R1 ^: y4 V full_path = %word_array1%; }( c3 c. v+ N" q3 h7 V. m
; strip to bare address
. Y0 T4 O w: u. @8 m0 g6 P* ? full_path := RegExReplace(full_path, “地址: “, “”)
7 b, Y& N% ~7 M8 o ; Just in case – remove all carriage returns (`r)
& q; i1 i4 Y) j; Q; r/ S; ?; T StringReplace, full_path, full_path, `r, , all) K# o1 A3 P+ R5 ~; I- }
IfInString full_path, \
9 S) e" N$ ~! ^* H5 _( e {8 c) e) ^9 B' c# W$ E. Y" u/ g
Run, cmd /K cd /D “%full_path%”
- N& R, N( k8 Y6 k& m# n+ u U: g# t! W$ k }
8 ]2 b% E$ Q$ q; k5 }- z$ {* s3 e else& L/ i# _; m" w# J ?' s/ o
{
, T6 t- `" y0 m6 K6 r( I Run, cmd /K cd /D “C:\ ”7 r* }/ q+ r3 C: t& _0 s7 u8 s
}
3 W8 s8 P& \7 M }1 Z' \) @" w- h- N
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。2 ^; C% [ I! N# ~& i8 A
这段小代码肯能有两个你需要修改的地方
6 t) r6 A( y9 t+ O1 | 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键5 [* a# J; E2 a' }& [) N2 h
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
8 I& e) \* b! v% w4 n3 ~3 z( t |