此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
8 q+ k+ \' E6 W; v4 w 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。6 s1 l4 x0 @5 D( O6 p
方式一:
% s5 D# K$ Y! L, z 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
% r" v Y+ M" K1 V4 t. T5 ? 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
, R* F% a& }& W( A% m& E HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
: l5 v$ J6 X1 r: E" }+ x 方式二:
1 T/ ?9 o! `6 Z7 p9 X* m 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
2 a& |/ K) l( y SetTitleMatchMode RegEx% m' F) f r5 ~( J% V7 ~7 h/ {
return9 C0 L6 c9 F# Q3 o2 E# Z) I% Q) d
; Stuff to do when Windows Explorer is open2 }. g, F1 {& p, @7 [9 X
;! N% `4 @# y' {$ J- p9 c% ^" B6 M
#IfWinActive ahk_class ExploreWClass|CabinetWClass
) P2 S1 [; ]+ R: d5 d% V( t: y1 Z/ P ; open ‘cmd’ in the current directory% d6 A+ Q2 n! Y$ S3 H: _/ u3 {5 |
;
& F) g2 {! Q6 T" c6 @+ D #c::: T" c( x6 u4 U; J
OpenCmdInCurrent()
' @% w' t' J& s9 C3 }( R( M return, h# k# e5 N& E' L' P+ c% ^
#IfWinActive1 N* Q+ C9 A4 P& m
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
7 ?* ?, H8 K' G! _ ; Note: expecting to be run when the active window is Explorer.9 q& X+ L+ R2 |8 w9 m7 F, Y; f
;
) A' h6 C$ }2 M OpenCmdInCurrent(): C- V# o% o8 x3 J8 ~
{
+ w' N2 ?& L3 E: A7 e8 ` ; This is required to get the full path of the file from the address bar
+ R6 U4 b" e- G8 U1 c" Q WinGetText, full_path, A
3 B* `$ u2 K9 q6 R, M2 o* c$ B3 d ; Split on newline (`n)
$ |0 ^( U- S* u- e; S: o StringSplit, word_array, full_path, `n5 o. m$ c' F' K
; Take the first element from the array
9 m0 O3 |2 d7 T5 m* b; D full_path = %word_array1%3 H5 O5 ?# W5 }6 `$ j
; strip to bare address
' M0 L1 B5 A3 c: t full_path := RegExReplace(full_path, “地址: “, “”)) c6 t2 U3 g/ A( K2 x5 p5 I( \
; Just in case – remove all carriage returns (`r)5 Q; X. q4 C1 R
StringReplace, full_path, full_path, `r, , all6 f# o6 x9 x. e& k0 t& k4 Y6 I
IfInString full_path, \
* X, I- I) H$ u0 i$ e% c) }+ s {+ S$ L7 S1 }3 n4 k* k- a5 n
Run, cmd /K cd /D “%full_path%”
& r& [* y0 y* F, y- \1 J }+ C. H/ |! f' g% z' K
else* u" {% j. e% v' O# d& R
{) Y5 }4 {" F( K/ H4 @; l! r
Run, cmd /K cd /D “C:\ ”' B# X3 V9 r$ w+ y1 @
}4 x* c3 J; `7 n+ S2 D4 z. W
}& P' d5 Y( A6 c/ l( y# j9 H
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
+ W6 F) E8 I5 Y, Q+ B3 ] 这段小代码肯能有两个你需要修改的地方5 [9 A% ?) ~) p
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键5 |- Q6 ?. S% `2 {. Y
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “/ H4 _" L: {; k! E' K s
|