此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。3 d9 v7 X# `5 R3 J/ j. o& X; j* u
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。: I! ^3 E/ g0 A
方式一:$ L o$ L( H: d, ?% r! E# j+ a) q
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
5 ^1 n9 Q7 x. f7 h5 _ 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和) ]: \: b9 K; i7 [3 Y
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
& O2 K- E4 Q9 |- q 方式二:
# _8 j, a) n. R, R7 [, A 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
3 h$ w; O- k6 \ SetTitleMatchMode RegEx; r% h3 E/ M! b+ t$ |1 _
return
! Q* [+ g9 E0 |5 N7 Q4 q ; Stuff to do when Windows Explorer is open
! \: I2 {9 ^0 v ;0 ?( H; F9 z& z# p
#IfWinActive ahk_class ExploreWClass|CabinetWClass) n' |" u$ H6 J* s: v
; open ‘cmd’ in the current directory2 W# E9 u/ b8 t/ r8 m
;
: ?, @, J' u* Y2 N: O #c::; { d. e! O. \; B3 I
OpenCmdInCurrent()' t- V H3 f0 t% q+ V4 @" U; d! i: T
return
. v% W# Z% N3 K! S& n0 A #IfWinActive* E. y6 i5 v0 ?9 b8 f" y
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.; c0 c6 q0 t- A& f4 p& M0 y, r
; Note: expecting to be run when the active window is Explorer.* S ?" ] u: m* P7 t' M( W' e
;& _: L9 e. F+ ?, m) a' W. {4 h8 Y
OpenCmdInCurrent()( Z1 ~8 A9 p0 Z# k1 O
{
! y( D' W! Y& f! c+ | ; This is required to get the full path of the file from the address bar
3 M3 ~3 c( l& q% O WinGetText, full_path, A
) _8 y- v4 i9 V2 `$ H) T) u, e ; Split on newline (`n)4 Z$ b0 {- l4 `9 f" O# c& f
StringSplit, word_array, full_path, `n3 c& l [4 d& [+ \/ }
; Take the first element from the array
( t8 }' j; |1 a7 | full_path = %word_array1%$ k3 k- D/ p6 d9 F9 X' \* Q1 i
; strip to bare address
: b3 Y) m6 }# x1 v$ q full_path := RegExReplace(full_path, “地址: “, “”)- z; P$ ]% [5 Y* I; s d
; Just in case – remove all carriage returns (`r): h3 o1 L6 q2 z R4 e' n) ~( _
StringReplace, full_path, full_path, `r, , all/ p: j$ c7 x; k1 q- L, ~; A4 x- N
IfInString full_path, \0 j( e% t, E# ?4 }
{) @' a0 U- a w7 ^
Run, cmd /K cd /D “%full_path%”
1 s& @& [, G0 ~; U- N- r3 W0 U }. P/ N" ~( [0 f/ S! |' y( m0 e3 a; G) W
else
/ r0 F% [. ^! W( Q {9 K* [! P5 s% y: u5 w
Run, cmd /K cd /D “C:\ ”
' Q6 |, j* }' t( R' R, }9 m }
4 A* U' ?( w% g! D- t( x7 K }9 m7 Z6 W& J. C- h
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。4 t- ?# L7 G1 ]. H5 R
这段小代码肯能有两个你需要修改的地方
( w9 m# c, p, e0 J6 U( e. @* H c 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键, ]- N3 T2 c9 `8 S
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
c! k& O' n/ n. y8 ]" d |