此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。+ ^& q' D k1 p; Q; S- O2 P
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。& J7 @8 Y- v( x& s# H- ^/ F' |
方式一:
d8 {% ^, T! Z; f# v 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,# e, ~# f( ]. k
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
& [5 n: B, I* I# c" d HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。9 w/ O% o7 u2 F- [( O0 r5 t# x
方式二:
/ n! x; {. k/ B# r5 q3 _ 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:: E f4 G/ a& Q# f+ S. i* ]
SetTitleMatchMode RegEx; ?5 d% d! J" x
return
1 g( x! h/ `+ _/ ~" x- k V Q ; Stuff to do when Windows Explorer is open
1 x( U" N" M2 v) ?3 U2 u5 I ;
3 \) J, t5 f/ x/ c4 _ #IfWinActive ahk_class ExploreWClass|CabinetWClass
2 ~/ L2 h" W# q* N ; open ‘cmd’ in the current directory
7 m- X) K8 y( G/ p. o ;* z4 |& h% C9 C) u- [3 }2 { s
#c::/ f$ A/ j' P I% y3 d' C
OpenCmdInCurrent()4 A2 C/ R0 d& G2 k% x
return
0 G! }2 i) o J% K$ Y) c2 i; {: W #IfWinActive# C @3 O5 I+ s& l/ q5 g
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.# J# O# \' j; p/ L, a* ?
; Note: expecting to be run when the active window is Explorer.2 H/ D( E# z( W& ?
;- d6 j7 X2 u5 N+ S+ O/ G
OpenCmdInCurrent()
# D% M9 Y+ x6 F3 }- n* Q5 Q/ T( k {7 \: m. }& q. s1 S, Y
; This is required to get the full path of the file from the address bar
6 Q, p# }; O( v7 b! T1 ^ WinGetText, full_path, A
$ f, j; y! F. w$ o$ z0 D" x ; Split on newline (`n)* T- c, P5 k* a b& X2 Z4 d: q8 {
StringSplit, word_array, full_path, `n& Y" U |- T F
; Take the first element from the array" D# @( c7 I/ D* e4 ]! ~
full_path = %word_array1%* [ |! a/ h$ \" I. |) q; m
; strip to bare address
" |& O# m, Z5 I1 R) w full_path := RegExReplace(full_path, “地址: “, “”)
% d6 b" ~6 V8 t# Z. S ; Just in case – remove all carriage returns (`r)5 F4 M. A* O4 c- F+ c j& A5 \
StringReplace, full_path, full_path, `r, , all
* N2 Z, }1 z4 `+ O' s% M IfInString full_path, \1 |5 I5 i2 z9 F
{
. C, q4 g2 G: s5 @2 t Run, cmd /K cd /D “%full_path%”
$ r+ u M* W& |) _2 M! Z, T }, }2 r, o( _+ |0 T0 W7 h! A. h
else
6 z) e( A( t% ^/ | {
3 h: }- z; A4 x2 x9 I( p6 O9 K Run, cmd /K cd /D “C:\ ”8 i: ?: T9 a- b( n/ g* w
}
' {3 M: Y1 ?: C& @* K8 ?( \" S( b, l8 w }
8 b2 h& @4 U2 p 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。' W1 M, K0 I# W' k' ^( Y/ p
这段小代码肯能有两个你需要修改的地方& s8 ]: b* O, Y2 V9 n- @) l8 Z# B, G
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键, R& l. B6 u% b
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
8 |3 c/ f* ]: G" A" w+ K/ {! P |