此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。1 T- b* I4 |7 v* ?$ W; b
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。4 B" @/ y+ I& V! j; ~
方式一:
5 Z2 `: H {* Y. A+ a6 H 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
, b0 y' A% p7 W/ t& D+ Z% n 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和3 |2 s7 J+ o/ ]( z( h. V
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
: }5 D. x; t- e8 H1 U4 }/ U 方式二:
# w3 K( v* [+ |3 X0 a( k& g 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
5 |9 H. q2 W, n' k X" o SetTitleMatchMode RegEx
- M& D$ r7 [% }5 V- ?3 g# M return
, b5 D& G/ Z" ] ; Stuff to do when Windows Explorer is open: G" O D1 c- M, R& G: g
;
! d1 t8 Z$ } K! d, n5 @ #IfWinActive ahk_class ExploreWClass|CabinetWClass
: _8 c" S' i9 L+ |% g5 J4 B ; open ‘cmd’ in the current directory7 _# }$ Y3 N4 L- d1 |5 k
;
& H6 l$ `) M9 | #c::
( Y V. O# W- l; d* ]1 i OpenCmdInCurrent()! H7 j) v7 e9 }
return
/ f9 Q/ A& M# p# T" P! n1 N( g, y# D #IfWinActive8 J1 y" M! j2 u. x
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.+ y* `7 }1 J- v2 @/ Z
; Note: expecting to be run when the active window is Explorer.1 }% |4 U G) g6 c
; l; R' M; F2 g
OpenCmdInCurrent()
0 W3 }( e% n) I9 N {
1 p; |4 ~) n1 M0 T1 Z. g& Q) M' Z% p ; This is required to get the full path of the file from the address bar% e9 G$ h. l9 Q& u9 k* Q" F
WinGetText, full_path, A
5 I& ?4 g& l9 B5 G' o7 q( e ; Split on newline (`n), Z, e# Y( l+ Q# u; }0 w1 M8 W
StringSplit, word_array, full_path, `n
- M! R @! X8 w5 {! J# I ; Take the first element from the array% g+ r( J; q" f8 _
full_path = %word_array1%9 W! W/ h3 N$ Q R% z4 e
; strip to bare address0 u6 @) S! c6 { k( S& ^
full_path := RegExReplace(full_path, “地址: “, “”), I- H ?7 j- s0 v
; Just in case – remove all carriage returns (`r)
2 }4 h1 Q, `# U6 m& I1 j( O& n StringReplace, full_path, full_path, `r, , all
# O, L# y# w; G% i IfInString full_path, \3 R1 A2 n! n, A+ Z. Y/ A
{. e2 b& }) c: Q8 Q8 m1 n8 H1 [
Run, cmd /K cd /D “%full_path%”
5 q( B9 D7 a- u+ {/ e* x }
, I: m M8 s& d) o! q1 M6 V else/ u; g2 C2 e# @! K) |) z- }5 I1 e! D
{
' n. Z: V* @8 B; \ Run, cmd /K cd /D “C:\ ”4 Y6 ]0 Z% R8 A* v# {
}* ?, ~# d4 P# Q6 N
}) ?: \. Y$ s8 g) | o d
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。# o( Z" ~, E: p* W- Q+ M) P% ?
这段小代码肯能有两个你需要修改的地方
+ [' {6 y# X4 @ 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键, S# }4 J+ I2 r3 x$ e; L$ S* ]
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “8 R6 K% z+ v& F) a& O- s; m
|