此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。1 c8 S* [% H+ } L1 K. g
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
, B4 [/ a4 ? e 方式一:
3 `( g' B0 k- T! g; T0 b 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
: p& i% ^& y5 `6 C/ b0 {* c& ` 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和, }& O2 X% |, i6 |. b
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。/ G7 J9 u) T' V) _
方式二:0 E/ V5 _1 O9 J( s, b9 }
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:2 \0 d$ P. c p4 C8 V; F
SetTitleMatchMode RegEx {0 a* x2 F3 w- t/ L
return
8 G) {, Z6 p" w( e2 J2 u% D. G$ @ ; Stuff to do when Windows Explorer is open) h/ S- N }8 N
;$ Y( K( Y3 C& s9 S6 S- F; Z
#IfWinActive ahk_class ExploreWClass|CabinetWClass/ _) j/ C$ I% i: j% g6 \
; open ‘cmd’ in the current directory1 Z, b" |( P. q) h- [
;! O( I3 A; r7 H( {+ _
#c::
: B4 O0 K* K) z OpenCmdInCurrent()
, G: e" Z; r9 Y+ X B& [2 m return
% N$ M9 c5 N' [ {& U& B9 i3 l #IfWinActive' |: y9 t# ~% K/ o3 h
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.( n5 F! P$ E6 \
; Note: expecting to be run when the active window is Explorer.
1 J; P& d. A2 e5 t' @$ J/ u ;
' h9 n8 C, e, X2 n! m: p OpenCmdInCurrent()1 _1 F- ?9 _0 K* d+ G5 w
{
: x% Y, q8 @( ^9 l* } ; This is required to get the full path of the file from the address bar, f1 u' k+ |8 T6 q
WinGetText, full_path, A8 i2 e( c5 ^0 Z) U0 Q. g6 O& Y+ i1 L
; Split on newline (`n)3 i- ]! w, @2 V4 M
StringSplit, word_array, full_path, `n8 n" @( e. S Y) \
; Take the first element from the array8 }$ _# ~) d7 W, t! J$ Q
full_path = %word_array1%
2 @# m. \ t7 \) Z* o. ~- e ; strip to bare address
' ? Q8 T& U; Z/ ]& ?. _ full_path := RegExReplace(full_path, “地址: “, “”)
3 P$ U* D" E) r( Z& w' Y) w- F: S ; Just in case – remove all carriage returns (`r)" U' G! D7 [" R; }" n0 [
StringReplace, full_path, full_path, `r, , all
/ v2 l+ B7 M% x/ A IfInString full_path, \
0 x6 p. V) A" E, Q8 S7 c {0 p2 l( ~. C& s' Y
Run, cmd /K cd /D “%full_path%”
4 }! d0 `; z- N$ O* @" \ }# K; {2 u5 O. Y: Y/ g9 Q) c
else8 w* z8 y3 k: Z6 H* X
{, H3 e/ u: l& H- m! N
Run, cmd /K cd /D “C:\ ”
* k' n( l0 a0 R5 a8 `; v# t& { }2 y! l5 `1 ~2 ~' H1 E- C
}
% ]( r) |+ d9 T! t 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。! D$ y+ M3 I" ^
这段小代码肯能有两个你需要修改的地方! n! S, C1 @4 ^, T0 L
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
]! h% J4 r" ^ 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “+ ~. M, t( E! j
|