此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
; a8 A+ \+ E) d2 h# l* R% g |" Z6 a 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
# X( Y: Z; s- D# u9 N 方式一:% r3 }7 X2 s/ [3 B
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,0 M3 q, q, J5 ?4 B# }9 b! @ y
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
" V) I& W8 A" L2 B0 d) T3 X HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
4 k3 G' e; Y3 N: L/ b7 y2 X 方式二:
K9 C1 `$ z, s$ z 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
8 p8 I( a* H# k SetTitleMatchMode RegEx: l9 V' N+ H1 Z# d1 L' ^& C
return
2 U# j6 E I! q8 Q* e4 ~ ; Stuff to do when Windows Explorer is open+ q ^( o2 k, z# {" T
;
( p2 q) X) U* ~& U7 p7 W #IfWinActive ahk_class ExploreWClass|CabinetWClass" Y- p) O1 a! u1 O' q4 D! z
; open ‘cmd’ in the current directory7 Z( b6 s% M- J) v
;7 j& d/ c( G5 Y* N( m E
#c::
], v. y6 x1 D, G OpenCmdInCurrent(): z4 @5 j" C5 a0 a9 }8 S2 U
return z! ~5 c# M7 v2 ]1 n! G p
#IfWinActive
9 U* S9 L5 q- L4 Z: }# p ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
' Z! e% S, Q, d, A* K2 F ; Note: expecting to be run when the active window is Explorer.
d0 r; L% ]' X5 N ;
2 Y- C% V0 l$ q8 {9 Z& F OpenCmdInCurrent()
: s* Z M7 t% ` I" d) e {
s" D4 H$ v4 u ; This is required to get the full path of the file from the address bar' n _( `. E0 r+ m. Z
WinGetText, full_path, A
4 N" c0 F$ W3 f9 O+ T! z2 J ; Split on newline (`n)/ x8 ~5 q1 c( [2 z/ U& W8 G. P
StringSplit, word_array, full_path, `n' V* u9 P+ }- z% s
; Take the first element from the array
3 j% |2 d" F( P7 d, p6 h( v8 B full_path = %word_array1%
0 [2 B- @* B# C; N ; strip to bare address
' N$ _4 D$ f+ b+ N6 i9 M5 i full_path := RegExReplace(full_path, “地址: “, “”), W2 ?" N8 y$ T% t: o& M8 @
; Just in case – remove all carriage returns (`r)8 @; }% u& ~5 L) M7 ^% I
StringReplace, full_path, full_path, `r, , all+ E* [% C7 r/ _1 [4 H7 s' v
IfInString full_path, \
5 I, s; {' k+ z- T8 k {' i" a- T% T1 Z) P5 ]3 N3 {
Run, cmd /K cd /D “%full_path%”- u. n" ^, U2 ?& h# U# K. A
}
* A/ D3 Q; ]$ j( l4 O else; C, f$ u3 G" k( v6 }# H% D$ I% y
{
$ ^6 [7 Q- z g3 S Run, cmd /K cd /D “C:\ ”
8 d( N& J+ _6 g0 h6 }( R! R }; U- D" v. g( V z7 }4 y
}
, h6 ~' K! t2 J+ a: l9 ?" X 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
! B6 j8 {+ x' P$ R- \& T/ ` 这段小代码肯能有两个你需要修改的地方. o- u2 R* Z- j7 r: t+ O
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
$ I+ f8 C2 q" m; ` 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
& |" w, A1 J% N9 t$ I6 C |