此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
0 e9 c3 ^5 d" V) j& G0 Q# v5 h 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。3 C) W, Y6 H0 X7 p6 n: ~! P0 K
方式一:; v# Z; g e( H; u
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,; p6 q9 R# a. O/ u6 l8 G
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和4 p" t9 D( m% K! [0 M
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。7 W! C* P( ?7 F. S+ H& p$ h9 L8 t9 R2 _
方式二:; G( A9 R" t0 Y. k( C
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
' L2 p3 P& @' X) ~' C1 u SetTitleMatchMode RegEx
: i+ Z4 w1 O" K4 ~9 L2 A return; q4 J( S* C6 w* ~
; Stuff to do when Windows Explorer is open
% Z8 y+ _1 ^: \; c ;: V2 t: e+ g; {. _1 h2 j
#IfWinActive ahk_class ExploreWClass|CabinetWClass/ l# r( X$ o/ R( T. x
; open ‘cmd’ in the current directory, H2 ~# c; F0 P' r3 ^' C/ r* Z8 }
;+ J, V, D" j* q% l" f) X3 W. H
#c::- {4 g. K% H0 _7 j
OpenCmdInCurrent()
+ Y9 o, Y6 k( \" W! c( d return
6 e+ b+ L) ~: o( _; ] #IfWinActive
@- r% O# v A ; Opens the command shell ‘cmd’ in the directory browsed in Explorer. j) X$ i7 l% M
; Note: expecting to be run when the active window is Explorer.4 Y ?* Y' c7 e( Z1 |
;
5 R3 I0 K6 [* M( H4 e OpenCmdInCurrent()' T+ V; Y: _8 D* [; U5 v$ R/ k
{" c/ @/ i x, e
; This is required to get the full path of the file from the address bar7 v/ o3 U" j- }, l: E
WinGetText, full_path, A
( R6 u8 [7 U2 p$ E/ ]2 L( P6 c ; Split on newline (`n)
1 k+ i+ J' A- E; ~# H R StringSplit, word_array, full_path, `n/ G" c3 M3 s4 A% x/ c+ M
; Take the first element from the array9 z( k" C) Q* }4 s! s. X
full_path = %word_array1%
% f8 }5 q( H4 ?) q5 x) S I O4 f/ u ; strip to bare address
6 h+ G" T$ m0 V- t B8 ~% v! J; j full_path := RegExReplace(full_path, “地址: “, “”)
/ q, z; R" u; R* U# K% B ; Just in case – remove all carriage returns (`r)! O6 ^5 p3 f( s7 r8 w9 ^# W, |: h
StringReplace, full_path, full_path, `r, , all% |, j; R1 s2 X+ W
IfInString full_path, \
8 \. A! G$ ~" x, T. y: X {& W) [' H. E: R# A. N
Run, cmd /K cd /D “%full_path%”: O( L. L) v6 ?) v7 h+ @
}8 i' C ^) h/ H9 b v% `+ e6 C9 q
else4 L! v% n! _" t2 ~
{. U N2 r, f; I
Run, cmd /K cd /D “C:\ ” f! k& \ ~4 T# \+ n8 S
}
2 |. I m, C0 g2 u1 m1 E }% T/ i4 G% V% z. A: K" w% P
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。( Z( d' E& J! \8 \
这段小代码肯能有两个你需要修改的地方
, G1 j8 R1 g% U& z 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
' O& {2 I9 t' l/ c2 v! ?& z7 r 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “4 x5 t E# t0 Y# z# i$ F) B& K
|