此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。* o/ n" b: j/ s( _6 j- P) ^
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。7 ?! u4 @( d3 L
方式一:+ `; r. d0 ?3 b$ Q
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,8 a j) l. o+ z& {7 s& z
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和) |# p Z, a; o3 O
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。& L8 P8 S: ]1 @; w! _
方式二:& d* S% r; p3 Q
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
8 [+ \5 M+ Z n" ?5 g1 Y SetTitleMatchMode RegEx
9 v: {1 {$ g- h8 l return
0 r( }( w: H+ S, r$ E% o3 @' t7 f* u ; Stuff to do when Windows Explorer is open
; _% E% a( X8 v9 X( [ ;
; U" m0 m2 i3 `8 t# }4 A7 H8 I #IfWinActive ahk_class ExploreWClass|CabinetWClass9 k6 u' C1 {6 V/ d+ N6 D" @
; open ‘cmd’ in the current directory% ^: c7 q. n; B
;
2 ?& u; L4 x4 \/ ~# B #c::
# K4 k( f# U1 ` OpenCmdInCurrent(): a- J; T) S5 B
return$ Q# W' N2 {8 }* W
#IfWinActive
. E( ?1 Q% N* s/ k& ` ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
+ N7 \, K: s+ F/ o ; Note: expecting to be run when the active window is Explorer.& w, i% ~$ A# ~& i% W
;
1 V+ S" Q/ G9 L1 Z. Q e OpenCmdInCurrent()* S9 k9 W0 _" x8 b1 s2 X
{; r' H( H$ E- k5 ?: p
; This is required to get the full path of the file from the address bar
3 k2 J/ Q& d) K. |7 S. S, Y WinGetText, full_path, A+ d2 [& N$ a3 }
; Split on newline (`n); t' p+ G8 Z4 ?
StringSplit, word_array, full_path, `n
' O" j* s; ^9 T" d B9 h ; Take the first element from the array3 A8 c: U% S+ p/ ^- K; p
full_path = %word_array1%
2 j' }* A- D% |% c1 m ; strip to bare address: Y: B* c+ l. v* p9 c5 h# G
full_path := RegExReplace(full_path, “地址: “, “”)
+ u( x$ g1 a! F ; Just in case – remove all carriage returns (`r)+ v' {7 S+ r0 o5 V9 e# x
StringReplace, full_path, full_path, `r, , all8 R# |/ F. X! `6 r. C& T
IfInString full_path, \ w4 \$ D8 q3 e7 d k4 w
{/ ?; i5 L, |, b- ?; E
Run, cmd /K cd /D “%full_path%”3 M6 a- i% x3 Y" L% x
}
" l$ B {9 ?/ o; b& I* P" n5 D else
# J8 w( x$ \& H {
; ?4 I0 f7 ~0 }5 Q2 U' a9 R" B Run, cmd /K cd /D “C:\ ”
9 d2 E9 V/ W: S }. B3 X, ]& h; d% ]; J
}0 m, u, \1 m/ _& N9 A
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。0 }4 F0 j( s4 [* L4 ^: \" K% U& e
这段小代码肯能有两个你需要修改的地方9 l `- e% Z3 D' M) _ y3 q7 T
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
8 `% Z' t. q, g9 N: C 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
! q+ ^, j k: Z3 ^7 k |