此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。% [, H2 [" d! |; a6 \
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
* a- R" y$ p& ], [' M 方式一:! z6 G, M# q# j% n( u$ L e/ Q4 m" }
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,1 D1 b7 H& m* `; g }/ a
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
" }( [' w: j. V3 L' O/ i" @6 G. G HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。, N. c# z1 e, @* H% `% x
方式二:
. ]( Q% p) p; |3 ?+ y, e 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
$ t* l+ F, g6 o; ^, m! ? SetTitleMatchMode RegEx
8 s G$ {" n( V% c& U return
# b% s/ H) r: W, j0 r ; Stuff to do when Windows Explorer is open' ~9 w* r+ }# S1 ~ y [
;1 Z; Z3 t" w" m( L, j$ b
#IfWinActive ahk_class ExploreWClass|CabinetWClass
9 L2 G" G2 o' j& `8 x; l ; open ‘cmd’ in the current directory
/ P' ]& v1 p% H, U/ s ;2 p9 C* G6 Q* D, ~) A2 p& U- A
#c::: L. Z6 d; R$ n) i! ]3 d* z: t& V) l
OpenCmdInCurrent()1 Z9 S; e" ~; z
return, o+ K1 ^0 g+ l
#IfWinActive* P3 {& A* S0 h8 M% C* |2 ~
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
) A" a) c9 R* @, C7 |+ _3 @ ; Note: expecting to be run when the active window is Explorer.
1 j: j9 A- y9 @! e( v ;
0 H4 \& I" _' T2 B/ m# @& d OpenCmdInCurrent()$ l% r' N6 d- w' B8 `6 @: |- Z
{. g3 {# f9 c% l% j
; This is required to get the full path of the file from the address bar- H& q; H/ J- {# T( @1 b( A) Y* Y
WinGetText, full_path, A
: d) S' r/ v/ \ ; Split on newline (`n)
: O( S1 r4 m# x5 R StringSplit, word_array, full_path, `n7 B/ `0 |0 T3 l9 h: ]! ^% `8 r! P9 j
; Take the first element from the array! ?2 k* _9 ]2 u: x$ Q5 H# e3 Y
full_path = %word_array1%
+ e) X8 b. d1 ^, v9 v ; strip to bare address
5 Z8 A2 G( v0 r9 ^0 T, l full_path := RegExReplace(full_path, “地址: “, “”). e4 }& j/ a( k6 m# e# s
; Just in case – remove all carriage returns (`r): [) c' }! I, h J* g
StringReplace, full_path, full_path, `r, , all) B6 n$ Q6 b/ r" Q5 L6 Q8 H z8 K* z, ]
IfInString full_path, \
9 u- o. c* `; @' _* I" \" b {3 d1 Y* Q7 }5 d) g7 X5 E: n0 o
Run, cmd /K cd /D “%full_path%”5 b* r' Z2 z- A6 @( D& ?& W
}
) z7 q0 u- G6 J7 | M3 O else
5 ]" t5 F: \# x6 {$ I {/ B2 V( L& H7 o' L0 I
Run, cmd /K cd /D “C:\ ”
5 O0 {; U8 t d! k* _ t0 a }
2 M1 b: S: r: ?; T# M$ Y, S }
: O/ n4 o F. P" ~$ ]0 P 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。5 r# D- W/ `3 R' c- |- g, T* K2 C
这段小代码肯能有两个你需要修改的地方
$ L8 [. o" u0 O* P 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键7 Y1 J' C& A$ y( I/ e ^
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
0 _) V) `: w: D* w; q, G9 t0 P |