此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
5 {" r9 e5 x: m3 S9 H, m# d0 L 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。! {0 P% d* v+ f
方式一:
8 L/ h0 A# U1 G, p% @: ~2 C6 c 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,* Z _: z3 h$ D8 {3 n+ {6 m
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和" ~! b2 h4 z2 L4 A
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。$ V/ O9 y+ @, c* M; p
方式二:& _- }$ H6 N/ R# l
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
, n6 |- M- G, f* `* y' z" _3 h9 a SetTitleMatchMode RegEx
& S+ K& n4 k( L f! e1 T0 q. t* F( { return% u! s3 M! N4 e8 X! t6 n+ B7 v
; Stuff to do when Windows Explorer is open
* O1 I" b ^6 |+ b1 _0 R ;
+ W% H! y8 g. x1 P3 m* b" Z #IfWinActive ahk_class ExploreWClass|CabinetWClass
: p+ R3 W& W7 p* o( P ; open ‘cmd’ in the current directory
/ @9 R1 }% q2 i0 H ;
) S# A) V3 U* r #c::" P f3 ^9 q) H) V
OpenCmdInCurrent()
. J/ B) _& P( _; Y8 A' }" I- V, F return
% Z" b, x' t' \4 \' { #IfWinActive% q1 w4 R& T* l+ i9 Z
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
8 G. A& D( e H1 e9 g/ m" Y ; Note: expecting to be run when the active window is Explorer./ S7 A; S9 g, ~! F% ?3 E7 S
;- m3 l0 V$ L; u" o4 H% k
OpenCmdInCurrent()
" `* K& Y; E5 U5 D; e4 I' ^) P {- K2 o6 Y9 O& J8 p; J# J
; This is required to get the full path of the file from the address bar
8 f( a6 i& `! u* I0 y/ G' W WinGetText, full_path, A6 ^7 ]0 c9 p& W" E, {! b; T
; Split on newline (`n)
4 K0 z* M) c) g* ]9 G4 H2 S/ c! T StringSplit, word_array, full_path, `n7 N! e3 f: D! }) J; m0 C
; Take the first element from the array
( t! w5 ?& d* h6 f+ a- P- s full_path = %word_array1%+ L: Z8 I6 M8 f- d, d
; strip to bare address
. k- ~- P( Z9 ]" b# O6 |# @/ ~ full_path := RegExReplace(full_path, “地址: “, “”)* x+ o. Y# Y' G
; Just in case – remove all carriage returns (`r)
L b4 C/ w* X" d" V# a StringReplace, full_path, full_path, `r, , all
# U2 t% a% t( S7 k! J IfInString full_path, \
5 I `9 P) }7 n9 i: h8 M {
n9 r$ W% \8 u1 k) V4 [$ m0 |; d Run, cmd /K cd /D “%full_path%”2 T+ H2 [; y' w9 ?6 o& t
}6 C- W- ~; p/ k
else
2 S% c7 `) w8 H: O1 e {/ g' i) H- a' J' B" a1 [! s
Run, cmd /K cd /D “C:\ ”# n! J/ C, [: G
}
* A3 ^7 F6 X7 q }
- Y' S* ^/ m' F/ M 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
2 H/ _2 v9 k/ |% N 这段小代码肯能有两个你需要修改的地方) p# H' |7 P1 M: y. e$ C. k
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
# e! i i; ]. d9 H 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “$ T- _9 z4 p$ f# \. X( F6 [% u
|