此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。2 T! A3 Z1 ?7 ?! V; z( c
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。; _: ]+ m# Z6 B8 a/ j5 ^; a
方式一:; G6 }' b! R- k& n5 f! G% B9 a
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,( r0 Z' r: Q G B" ~7 a5 o
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和' Z+ J" D- e# _$ ^
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。0 z$ S% x; O- q4 D4 Y
方式二:
$ [+ Y" M4 r$ J0 V+ e 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
# @9 }" t) D. S4 S SetTitleMatchMode RegEx
8 o: S% f& m/ k9 N2 J3 T. W P6 u return; d& S& u; w3 ^4 f$ Z
; Stuff to do when Windows Explorer is open3 h5 K/ m. C# g
;
I3 \- _& q1 P5 Q& \* w #IfWinActive ahk_class ExploreWClass|CabinetWClass/ |& ~$ w8 u; ^; F" a
; open ‘cmd’ in the current directory
/ v( R! J& V% @* N7 z, X& Y0 ^$ ~ ;8 k5 w( d6 S7 _+ T3 [ _
#c::0 w7 s8 ~, h7 Q. Z; P* v$ l) k8 p/ z
OpenCmdInCurrent()
) W1 x: w; C" c. [ return
: p, B, `0 E0 @ #IfWinActive
; Y& D- X5 h3 H4 @( y ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
1 X1 r" H# r* B ; Note: expecting to be run when the active window is Explorer.: V- ^5 l- o( ^8 G9 o# x7 X c8 Z
;% d! X" f+ J* ^, q' n! \8 u, g
OpenCmdInCurrent()6 c" p. `4 ~$ G% d7 T
{
. c& c3 }5 N8 T, d# L ; This is required to get the full path of the file from the address bar
" o* I& X# f l" v/ z/ {! Z WinGetText, full_path, A5 i, f! [2 W. A* ?
; Split on newline (`n)/ k0 O a& y: |. x6 F
StringSplit, word_array, full_path, `n' h3 G6 k& y7 H! q7 d: B4 h
; Take the first element from the array( E" U; j4 t* a; F7 x8 u, e5 V
full_path = %word_array1%
, C! A! D9 s0 S" M0 q- G: _" x8 c9 S ; strip to bare address, L5 F& n/ r5 Q
full_path := RegExReplace(full_path, “地址: “, “”)
9 a1 T2 ~# P& Y; \ ; Just in case – remove all carriage returns (`r)& T6 v% b) B0 ~2 t+ o( c8 L6 F& i
StringReplace, full_path, full_path, `r, , all& M6 R" z7 \1 Y) k+ d( P# ]
IfInString full_path, \
J7 ~! i \4 g3 b; l: y0 {! I {+ z/ G* d6 s$ L1 T9 g
Run, cmd /K cd /D “%full_path%”& w' X. J$ m, B! Z3 x; q
}3 k; r& _/ X; v
else
; }/ O6 H. H9 I; ?9 h3 { {3 G' F6 r, H4 E8 w, q/ o; B
Run, cmd /K cd /D “C:\ ”
) M' m1 k7 s! C( Q: j8 n }
: ?. d( F7 U4 _0 _ }
. m0 v9 z/ g0 ^0 |* n& N 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
+ x; A. D# I; [. ~/ } 这段小代码肯能有两个你需要修改的地方! B( Q4 @5 B. o* N
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
X* _& v4 z% T+ ^% f6 k0 [ 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “' w2 t7 ?' G" v* V* ]7 J: {
|