此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
& U- h3 d" o! H; |4 @9 P 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
+ R: z0 D* }/ U' u 方式一:% i" N1 O7 s. T7 [5 g. @% r' k
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
n5 V; ^$ c. f* B! D4 f: f! U 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和4 t' M: X" R" m
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。8 c/ {+ q; P8 G6 |5 u8 a: x5 M9 V" ]
方式二:
+ a! E5 d* O/ B% D- Z! {/ x0 K( \ 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:* \, J) Q/ J% C5 L# T2 R- Q8 r* ~
SetTitleMatchMode RegEx9 T7 h- {: C; Z
return
+ U% V4 n' f. b ; Stuff to do when Windows Explorer is open! N5 \/ i9 _: ~
;
3 }) F0 M' d' [1 w5 ] u- H- U0 i #IfWinActive ahk_class ExploreWClass|CabinetWClass
# K6 g0 X2 e, W; K ; open ‘cmd’ in the current directory
5 p V; F( ] I6 _ ;+ K, z9 O" G, c: k1 q
#c::( x: u% q/ ?, L6 g6 m
OpenCmdInCurrent()3 x: x/ t- \5 J
return
; O; F5 U8 d! ?* v# n* `3 p #IfWinActive
# h, }- d3 J/ {) N ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
0 h' w7 n' Z* m+ F% _, G* k ; Note: expecting to be run when the active window is Explorer.
# ^$ S7 B1 h4 J: D; r( C ;
8 `( f7 Q! \5 E. ^: r OpenCmdInCurrent()5 l5 q( e. q9 v4 b1 q
{
6 E' L2 e7 ?6 H& G& Y; Q ; This is required to get the full path of the file from the address bar- z* f4 z% S& V- M
WinGetText, full_path, A
$ i2 m2 F$ h& P J ; Split on newline (`n)2 e& n* k$ v4 m& Z" i
StringSplit, word_array, full_path, `n; X: A5 e9 ^+ h. @3 x, I
; Take the first element from the array
9 F4 ~6 F& C, H# U- O full_path = %word_array1%
8 v( `* c& `0 D! w2 h# ?# T ; strip to bare address
+ o v% A# n. k full_path := RegExReplace(full_path, “地址: “, “”)! V/ w* ^4 y7 d2 ~/ ]* l7 b
; Just in case – remove all carriage returns (`r)
* h l$ s1 f5 p; r) a( g- h StringReplace, full_path, full_path, `r, , all4 k- R$ m8 |8 a8 E7 w/ F& i4 l: U
IfInString full_path, \9 f' [# r; z6 _
{
1 S. A9 m1 W: H Run, cmd /K cd /D “%full_path%”+ j/ u- m4 ]) d
}
0 V% Y+ V6 p3 K% u else
, b: P; r, [ _- F7 ? {
# U1 u) r" m; s- |/ y3 Q3 ?! L5 m Run, cmd /K cd /D “C:\ ”4 q5 H& N, P; v7 m* W
}, u/ C8 O' Y4 O
}
+ S- P! M! Q, g' i: f8 P4 ~ 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。) z% m, N" q7 U) A
这段小代码肯能有两个你需要修改的地方2 A/ v5 T6 H- |) D/ z U! K4 S% f
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
9 r* }3 o/ q1 E6 w 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
/ r% A' Z' q& b/ h/ c |