此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。 @: w; d6 h4 `) k7 C
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。% L$ v" J. R+ R( m) T+ u
方式一:
; B( U J+ B1 J( m1 I 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,8 S4 r# S, c2 |* g) c
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
0 H8 T7 h6 Y' V; f4 R. u7 | HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。5 ]" @/ [* o# s# j$ ^
方式二:
, V2 p+ n$ c7 u. i" k0 t 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
$ `7 |8 f0 c. Q6 O; d SetTitleMatchMode RegEx, V: |1 p7 ^6 H
return
' q( n. N7 u4 C: K- R$ J- T9 i ; Stuff to do when Windows Explorer is open2 O! V1 u% w2 p$ `
;# a5 N3 e: S2 N9 X/ X! e
#IfWinActive ahk_class ExploreWClass|CabinetWClass! J% c* F: y9 t" A/ K5 W% X) V% G
; open ‘cmd’ in the current directory
! O6 t3 S3 Q6 W* p$ F ;
8 ]& r1 ?0 A; T9 G3 [6 X #c::
, E5 h4 p2 \/ x9 W) l1 K! @' t OpenCmdInCurrent()6 T) f) @ b4 D3 V* }+ D8 I7 s0 e
return
* V: e% C/ p/ f5 p' @ #IfWinActive
/ M, w0 t& J* u& j ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.' {3 M+ a. ~/ J& e: }" e
; Note: expecting to be run when the active window is Explorer." u: @0 N3 w, h8 m
;
4 N7 q' A" a, d' m OpenCmdInCurrent()
$ U& M2 |+ f/ \4 V) l h {; y6 ~5 A6 m3 [
; This is required to get the full path of the file from the address bar
/ y" x+ Z6 e& H WinGetText, full_path, A' k( r8 x* Y/ S5 a, e0 ~1 k, X
; Split on newline (`n), P- D! b* {. {( \" ~4 e* Q! [
StringSplit, word_array, full_path, `n- v9 R. X! w( U* l
; Take the first element from the array- N7 A! s& T3 L0 c# I6 C
full_path = %word_array1%* r& F9 o, p }. K) m( p4 p- a- G
; strip to bare address
8 p; L ~' ?3 m* e full_path := RegExReplace(full_path, “地址: “, “”)
+ C* R, p. u" ]8 d* A" n2 _5 g ; Just in case – remove all carriage returns (`r)
& `! H1 D7 d8 o StringReplace, full_path, full_path, `r, , all, z8 m* J1 Q' n/ F
IfInString full_path, \
& J) p0 d4 s# {. f0 I$ A {0 N5 ~' f' a. d# ]- z* X# i
Run, cmd /K cd /D “%full_path%”/ C: v% i7 N1 g. `3 Z6 i
}
% n' |( b: q! Y else
- X$ v, n$ A' e {
+ i& _" N/ h+ M2 m Run, cmd /K cd /D “C:\ ”
* z4 I- U: K; } Y4 y% T }
/ f) O* ]# k7 o6 @ C4 w1 B, H# F: T1 } }- v# x, L* T! |
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。$ ?6 b" |, O+ _4 j
这段小代码肯能有两个你需要修改的地方+ p, @. b: |9 X: \" k1 V
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
6 Z$ `- c- i0 f( P 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
; `1 J% ]% w( k7 s, H* n1 ^ |