此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。& _# l6 J( F5 o; \
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
8 ^2 Z0 b3 V, F- C5 S4 a9 e- E 方式一:, J6 } e8 X$ B! W( U8 |9 z& F+ g6 m
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
6 ^' S% R/ e; T) t' i 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和6 |4 A% W+ H' i6 ?
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。" W3 p# u/ r W5 k9 C
方式二:
9 g% D: U0 y* b _; Y, d: B 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:6 `; C* {4 {9 @# |- E
SetTitleMatchMode RegEx7 z1 y0 s4 s1 E+ H/ @4 ?! T7 F
return
, t! v" g# [0 b ; Stuff to do when Windows Explorer is open& c# s" s, y, j$ u9 a! i* I
;
& Z( p7 h; [1 i2 m" S9 g #IfWinActive ahk_class ExploreWClass|CabinetWClass A3 X1 ?$ a7 Z+ X# A7 c
; open ‘cmd’ in the current directory0 q& J, P3 O/ m# ^" u9 P- r
;
6 Q( P( V2 \6 m. t! c& t4 D P5 G #c::
8 A' m: Q' }; v! m! ~ OpenCmdInCurrent()3 G# }* A8 h- x! a% ^) m) K* V
return
3 C# x1 |1 }- F9 M. W #IfWinActive4 P3 M1 ]; F" r" F! W
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
) D& Y. r6 ?5 L5 r$ a ; Note: expecting to be run when the active window is Explorer.
6 B: l3 y' ~; m. \9 {- Y% ]" L! C e ;- D. D& Y ^/ b0 @
OpenCmdInCurrent()
+ V; [! e6 J' f! S) B {6 }1 a" `6 [8 |# ?, ]" d
; This is required to get the full path of the file from the address bar. W9 ^4 n' l6 g/ e R' R6 }: T0 P+ b; L$ E
WinGetText, full_path, A# A/ E" @! a' Y/ [% W7 l
; Split on newline (`n)9 Q1 G; k3 g; h# v$ N E3 d- u
StringSplit, word_array, full_path, `n. j2 W+ l! k# P' q' O( w) i o
; Take the first element from the array
6 B9 ~6 I7 S, }3 U/ u full_path = %word_array1%
/ o5 s% J0 _# H$ v# Q( ] ; strip to bare address' H6 T( ~6 F. J# `* x
full_path := RegExReplace(full_path, “地址: “, “”)
1 u; g1 ]/ @/ s) J7 Z( m+ Y ; Just in case – remove all carriage returns (`r)* N) K1 C+ f5 n* Q5 I! ~
StringReplace, full_path, full_path, `r, , all
) H5 h' X2 w; \+ o/ }! t IfInString full_path, \
6 P$ d$ X9 g: _* y {
( {& j" }5 G* R Run, cmd /K cd /D “%full_path%”0 K6 z8 w& s6 w" A0 w; @7 }
}
& O& e" [' e7 M& O- x* t8 Q7 d' u else
; S6 d z, p+ Y$ L# m+ D. R9 v {
/ U' M2 c" z% Y+ ~ Run, cmd /K cd /D “C:\ ”/ S0 l1 H. e# d2 M
}- K' m" a E' S. l$ h8 e2 H$ z
}( Y5 L( l7 c0 q/ ?2 c, X6 i" o
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
; P' L+ t0 I( {0 U" B 这段小代码肯能有两个你需要修改的地方
4 @/ j% q- t4 U1 Q8 L- D 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
% K0 @* ^2 g/ |/ u4 X 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
. N# i6 R X: P9 M/ g; b |