此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
3 z3 } M# C: L" I 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。+ Z. n5 Q; X& _1 S7 W4 K
方式一:
# p* h/ E4 n% q) R* p 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,) g2 q. S* T; C% V. [3 _2 O: O9 L
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
( ~6 `* e1 B( \0 F0 _( u HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。# r, x4 c) H- _) i3 F: r" ]4 j
方式二:4 e+ H7 [6 R* L8 L& _
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:' U( J g# ^: o* V( \+ ^" N
SetTitleMatchMode RegEx- y+ h; V/ m- Q9 T3 H$ P' A- d9 _
return9 P# j) W0 h: L& D. B% \
; Stuff to do when Windows Explorer is open
4 q& W( n: M2 W ;
7 X% h( O# c7 H" u5 L #IfWinActive ahk_class ExploreWClass|CabinetWClass
+ x% L% y: o5 D! p/ _ ; open ‘cmd’ in the current directory
' a0 L& Z+ |9 d- d! w! D ;0 [2 r1 L4 `1 ^/ |; R+ z8 e
#c::3 Q! H, ^3 w% c$ ?4 T
OpenCmdInCurrent()6 x/ a. U/ h1 q0 Z/ y
return! e/ \; o4 c; x1 E% ]
#IfWinActive" T# I% K( L( n" q- a* d; ?" [
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.9 A! z8 {3 y0 d- X
; Note: expecting to be run when the active window is Explorer.4 m) c n2 |, \9 v9 V* ^" C; \
;
2 U) R5 J" S, }; p* a( G OpenCmdInCurrent()& n$ b4 p8 R+ J* V
{ f* Z8 W, ?6 }9 y( S- G9 O
; This is required to get the full path of the file from the address bar+ i# H9 B; N" L2 R$ L5 n) q& h
WinGetText, full_path, A
5 e6 g- Q0 @3 ]- m$ X" Q l3 B" H ; Split on newline (`n)& ?* q5 | N6 e; P5 z
StringSplit, word_array, full_path, `n
% y3 A- p% C* G: }0 z" B$ [ ; Take the first element from the array6 S: v* x* [# w/ g8 k- I0 f7 Z
full_path = %word_array1%
" R4 }, \+ W# q* s% @8 o ; strip to bare address
8 g3 y; ]; q4 C5 v# l$ m% X full_path := RegExReplace(full_path, “地址: “, “”): I1 o. c( S7 i
; Just in case – remove all carriage returns (`r)
: A, h% s( X$ M* t0 A( G$ t StringReplace, full_path, full_path, `r, , all
# q2 q4 ?. Q- A @ IfInString full_path, \
3 A. K9 t# d, A) ] {6 v) o# i9 y# H" R2 K+ r
Run, cmd /K cd /D “%full_path%”
% L; `2 t" V! R1 j; d4 v }
?& ^8 A4 d0 A& @* V3 y& W6 H5 [ else# k9 @% N @& ~- }
{0 u# c7 a; @# P d, g2 Z2 H @
Run, cmd /K cd /D “C:\ ”9 |/ f1 v; b4 e/ g! a
}
6 a, j, Z3 P& I$ v. I2 j( V; x& O }
9 H* j+ G5 E* G! c+ I 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。; j7 P& h/ q( l, B' n; F" u
这段小代码肯能有两个你需要修改的地方
) I6 C I$ Q7 j+ F' e6 j) l 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
0 t$ ~- P0 l) c1 W 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “: H) K/ `7 \- W* C4 U
|