此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。 Q% d& [2 g+ d! H
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。2 P/ R0 A8 d" t" x; E7 b
方式一:6 U) i9 a! v9 W& C; ~# g% O2 `
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,( Z t* _/ [" ~3 f
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
3 ?4 z$ F. u2 c HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
/ p& Q# L0 n, n 方式二:6 j2 Y/ ` ^4 Z4 I! t
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
# c8 I( u! q( Q. Z" b, u5 L SetTitleMatchMode RegEx( F# e j4 _# J& y) e1 R, m3 X
return0 E. d1 t y, f" T* J7 n
; Stuff to do when Windows Explorer is open7 {, g2 L; ?1 n2 a
;* G- I& i& }( i& ^9 j4 k
#IfWinActive ahk_class ExploreWClass|CabinetWClass
! |$ M( X7 ~$ [/ y9 J' O: t ; open ‘cmd’ in the current directory
4 Z g0 i/ S/ ` A1 y ;
5 G3 S8 s5 s- {! W' ~2 M" | #c::
2 ^- G! l$ x5 L5 ^0 `3 R OpenCmdInCurrent()
* }0 m5 M$ g& O1 A+ { return' o" z, X# Y% a4 Q; G& u
#IfWinActive7 [3 n( W: P$ f; A9 N9 x7 D
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
7 K! ^5 \4 w! S ; Note: expecting to be run when the active window is Explorer.
2 V0 h) y& b$ n0 Z5 C4 `& N ;
7 \6 Q+ _: X3 I$ q- P OpenCmdInCurrent()
0 o% ]# t/ V6 F9 V' F) H* d' d {
$ G. L0 [7 I8 ^+ W* v6 j ; This is required to get the full path of the file from the address bar
3 K1 Q% P1 w/ M% g8 X WinGetText, full_path, A
0 o* B, G1 n" x" q3 O3 R ; Split on newline (`n)
9 t9 \, a) Y* v/ [1 U StringSplit, word_array, full_path, `n' @* |+ R& D- P; r' m
; Take the first element from the array! M6 [/ Z8 Q+ k& v
full_path = %word_array1%, Y6 d5 z3 v& ~& b, S
; strip to bare address9 x; K+ x. q* g2 G) c' K
full_path := RegExReplace(full_path, “地址: “, “”)
! Z0 s4 f2 V3 u0 J7 j @9 @ ; Just in case – remove all carriage returns (`r)) x% k; n3 ^+ F
StringReplace, full_path, full_path, `r, , all
, ~/ A; Y( r& w8 N# G* R3 n+ U$ J- | IfInString full_path, \
* b4 t+ p' i1 W {$ E" p; m W5 Y E+ A0 ^* l- |
Run, cmd /K cd /D “%full_path%”
c$ f' ~9 y3 V( Z! @+ ~ }4 N/ l. R- [1 _* Z) l& \/ @
else* q0 E$ }8 R b+ F% t0 j0 V6 J
{
7 w* T* b" c4 O! y Run, cmd /K cd /D “C:\ ”% n0 J! Q! I7 ]3 n: @
}
! ]1 S0 `2 s& u$ q; l9 R& N$ q: R }
7 }9 [% j/ Z5 z! D( |/ G* {9 }0 [ 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。: B0 Y" h1 |) N. p
这段小代码肯能有两个你需要修改的地方
; Y: L- x. @, j" G8 t2 T M+ E: g) K 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键; A, m% A: i2 m% c
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
4 v: ~8 z5 N5 P! T' \7 T |