此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
& _& ~( N* J* `9 K6 Z/ X 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。) b: W/ x1 p( d6 O$ K
方式一:
5 f) j5 o' Q" g/ L 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
5 V8 Q' n" P: [ ?% o 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
9 j! e( Y& ]" O" K HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。0 T4 U; J! H) @9 e* o
方式二:
8 b' q$ p7 ~8 }/ c0 ^ 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
& |# G; z7 i1 i j$ ` h3 C3 y SetTitleMatchMode RegEx1 f3 W( I' {$ ~' S- q2 Y: L
return% c j: J4 e( q
; Stuff to do when Windows Explorer is open
% G% O* K( w- S1 S* `5 c ;+ {" P( J# u8 f, o! I
#IfWinActive ahk_class ExploreWClass|CabinetWClass6 f: D0 {# L* N5 I& k
; open ‘cmd’ in the current directory
: `1 N n1 ?# }$ g. x ;
6 ?; ]! H6 G$ s* s* t #c::
0 U+ i$ m9 u, W9 y* @$ m* c OpenCmdInCurrent()
/ N1 B9 f. ?8 S6 p# P/ L0 p) }. } return
( Z/ {4 _, H' Z! @1 C #IfWinActive
' l4 P8 W$ \& h( t: l4 J- T9 [ ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.3 |" \ @$ G* d9 h& M
; Note: expecting to be run when the active window is Explorer.+ E$ Y3 h7 e+ J
;
9 V# a0 @# H! Y3 ^8 z7 K: B; h. _ OpenCmdInCurrent()% d# z, Q; C+ C" c' t# L
{0 ]9 i5 V) J& e S& W6 {+ n( _% ]1 o
; This is required to get the full path of the file from the address bar$ |# x$ l- Z' N
WinGetText, full_path, A4 z% t6 S$ e* f5 |& Q! u7 C0 \
; Split on newline (`n) p$ q% C' q) M7 b1 d
StringSplit, word_array, full_path, `n! f/ e. q4 W7 n9 b& g
; Take the first element from the array
2 z5 \. z8 W8 l ]8 U full_path = %word_array1%) O/ b ~1 A' s! @' H" P
; strip to bare address2 n3 F% w0 m* g; z. Q- r
full_path := RegExReplace(full_path, “地址: “, “”)# F5 }" u% g4 l& @% N
; Just in case – remove all carriage returns (`r)# G1 n+ {4 `' P; ^9 K! [9 q2 \+ x
StringReplace, full_path, full_path, `r, , all/ g6 ]1 _" U1 @2 K
IfInString full_path, \5 M; A. s' h+ i$ y [
{- i( H+ p1 m1 w5 m& ?+ Z, l
Run, cmd /K cd /D “%full_path%”
6 P0 o! J" @5 G! a/ e7 d% I }9 k1 r, y, X) q% l4 U# E- o; ?
else3 e9 q0 G! g# m
{
2 X& ~7 X% f: H- u& u- E% _ Run, cmd /K cd /D “C:\ ”
6 w3 V6 C( e4 S, S$ r: Z6 Z9 Z }
( q) o0 ^; r1 A7 V9 x$ [ }
( I$ Q( r$ N' A: L* W. `; J 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。" ^8 h) X7 D8 B$ P- y6 A
这段小代码肯能有两个你需要修改的地方# H) a: r) c; p9 B; ]8 Y! X
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
0 Z0 ^9 b/ L' G! u 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
1 o/ ?5 ~6 G: d8 D5 ]0 `% B2 y |