此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。3 b2 F3 I5 o7 c( {7 ^
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
4 `; D1 _) @, ?( ^, R! v* ^ 方式一:! K* C* D/ b) `! m1 Q; H1 d x
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
B( y( C5 b$ Q; W6 C- v 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
8 G- f8 }4 H) X5 r- f HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。: I% k1 E4 z; Q p
方式二:
w3 F, R4 }% G" e 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
7 w. U4 i( D- {$ s" i4 I k3 }3 v SetTitleMatchMode RegEx# I8 e' A' p* e# T/ x
return
P( I/ m/ n7 p# k ; Stuff to do when Windows Explorer is open
- R( J+ R' W4 p+ X* i% n7 ` ;4 I2 h8 E4 _, j) c9 o, B' M
#IfWinActive ahk_class ExploreWClass|CabinetWClass) C/ @4 Y! l4 n8 l- q. g; D- {
; open ‘cmd’ in the current directory# i3 z" Y! ]( W* z, X
;
. D4 [' w( [# U #c::
( y6 c& G" f; D OpenCmdInCurrent()3 ~1 e+ ~- ]. V% R
return; r! Z$ }. ~+ ?; v+ E$ [
#IfWinActive6 w# [ D4 q9 z( k8 t; Y
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
/ M0 ?* c: m- q3 ` ; Note: expecting to be run when the active window is Explorer. O* B; h5 M' {. N; @) x
;
2 d3 ^, U7 G' K. `% A: X OpenCmdInCurrent()
* c: j/ K" s' @3 }) Y( ] {
" @+ L8 h+ u4 }: H- Z ; This is required to get the full path of the file from the address bar
7 L2 K$ {! W' S& B F# z WinGetText, full_path, A5 i" y1 d- E- ^% C" L
; Split on newline (`n)% l4 P1 m8 ~0 x) R5 y
StringSplit, word_array, full_path, `n( r0 G7 |/ E2 @1 i4 E1 E6 B& E; H
; Take the first element from the array, W1 i: F; s2 s) c8 R8 e
full_path = %word_array1%
- x4 ^8 P4 s& O! h1 a; f) B% }! i ; strip to bare address3 x' [+ Y$ s( K
full_path := RegExReplace(full_path, “地址: “, “”) f5 k" R8 F& U9 C3 Z5 K( C
; Just in case – remove all carriage returns (`r)
' r) F8 o% s! w/ K" S z( e StringReplace, full_path, full_path, `r, , all6 S% P" o5 j" x7 v6 \/ J. J$ N7 t# Q
IfInString full_path, \0 ~. N3 S, _$ \& J g
{
+ Y1 ?) B- ?4 v# O8 [ Run, cmd /K cd /D “%full_path%”# I; i0 r; r& |; \
}
, j) F" [7 I, X% n2 S else$ P4 Y5 W5 e# ?# k
{6 J+ K+ `; @* ^ e
Run, cmd /K cd /D “C:\ ”
4 }& i1 j. L! D }# e9 M, l U6 T0 t
}
* g% t; L2 P$ n! @ 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。9 ~7 Q9 }; X* [$ h5 y. |
这段小代码肯能有两个你需要修改的地方& E& u! j1 d4 x& Q! {7 j
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键/ I) l; r4 n2 }8 `& r( p
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “, B3 v) K! y! |1 n0 D; ^9 X8 F
|