此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
+ x( T+ T: p3 C& B: Z 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
, N" ~# F0 U9 u+ ~5 L( H* j0 U7 `% ] 方式一:
( o, j) c ~. V/ Q+ C: n0 |9 N 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
9 n+ M8 S3 ~- d% A4 W) o 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和" E) ?, f. d! O5 z
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
; _/ b8 K( P# n6 s+ I$ e 方式二:
- d+ b' r* c& ` H' _7 Q 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
2 J7 U4 |& U* Q; @5 X SetTitleMatchMode RegEx" f7 |* S( H* v2 E5 j; K
return1 J$ M+ i/ p. Y' t
; Stuff to do when Windows Explorer is open4 L" p0 X; c8 L D6 e
;7 A* u) j ?+ e" F
#IfWinActive ahk_class ExploreWClass|CabinetWClass, C6 ~2 J& j$ @ w, d' j
; open ‘cmd’ in the current directory# A2 r+ Z6 N# N' R( e7 l" V
;
- g$ U8 a7 Y. O: e: `4 T) Z #c::
8 V; z$ S8 Q+ P, w# H8 G' \7 Y OpenCmdInCurrent()
# Z7 B' c0 [3 b2 E: y2 [ return4 f3 R1 N# q1 U! _1 ~
#IfWinActive Y& }, A) W. _1 Q' R
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
9 p7 h& e1 G* Z8 M h, ?4 O2 h ; Note: expecting to be run when the active window is Explorer." G# q/ I0 J* ? o, U
;, q( [& m) M l! f) r! B- f
OpenCmdInCurrent(), K2 b6 ~0 i1 V9 T: V I( U/ @
{
" r5 N$ D' v* G# R1 q ; This is required to get the full path of the file from the address bar
& U; d% |1 y! N7 T4 v WinGetText, full_path, A
) P" r9 p" K4 P& Z4 Q( _3 v" e. A4 _ ; Split on newline (`n)) c1 t5 |. n- o; [+ h/ T
StringSplit, word_array, full_path, `n
; v; J# C4 Y' I) L/ U$ R ; Take the first element from the array
- \) d/ [9 \7 w7 \, C7 {' @- y full_path = %word_array1%1 b/ k" r; g0 h% m' T8 H
; strip to bare address! Q8 ~* J" _! T3 m
full_path := RegExReplace(full_path, “地址: “, “”)& w* |; |0 c Y6 I9 F0 B
; Just in case – remove all carriage returns (`r)' e- h( h9 t# k8 J, b- Z
StringReplace, full_path, full_path, `r, , all
) H* J) J" z# E" r6 G IfInString full_path, \
/ P! `" h' f l: i7 @. Z: X/ ? {
) n) g% }( c1 k$ H$ i( ? Run, cmd /K cd /D “%full_path%”* D: d4 u* C, W! F0 W# F
}
, x2 M- A5 U! P else/ X5 U: R* K+ `
{+ @$ B% `; ?5 V9 B1 t) G
Run, cmd /K cd /D “C:\ ”
% w# D4 F' q( H' ~# z' L }" R+ j# e$ b- E
}( [2 L+ p5 P. C9 }, i6 U
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
% | _5 u* ?7 k$ T% [ M ^" j1 i 这段小代码肯能有两个你需要修改的地方# n5 T% n1 _' K( V0 M3 p' C
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键 U. V/ j6 ^) G* }! i k
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “" @4 s0 Y" B5 C! u. o
|