此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
: L* Q3 r1 l2 f# j 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。5 D2 y- [2 p5 y0 X6 P
方式一:, A# N# _. R( [% | D- l
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,! d {% {" G$ A# ^" W( Z
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和" }" ~4 r6 j1 @3 _$ |# I( k
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
' E6 c$ H( G) P1 t1 Y8 ?9 z8 N( }) G 方式二:% T- I7 X+ p6 X: z9 k
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
. D1 {2 Y6 R2 M% x6 { SetTitleMatchMode RegEx0 c& d8 E+ j+ v8 Z
return
! j2 I% j( s- m# {4 x% ]1 r9 F* _ ; Stuff to do when Windows Explorer is open; B J1 K+ y' x* z/ x
;! Q& e! w' o# I+ y
#IfWinActive ahk_class ExploreWClass|CabinetWClass
7 q7 ~- ?2 P4 G, x1 [" x ; open ‘cmd’ in the current directory* ` @/ X! J/ V T" _# @; X2 J
;% i: x2 L) o, ]' f) Y8 ^
#c::
+ B4 O, M# X7 S" j OpenCmdInCurrent()
4 ~! e) t$ ?/ e% C( p return* f) L, M4 U8 n4 c2 x
#IfWinActive
j$ i$ |* ~7 r" U7 G7 P ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.' y# ~" o% I( q) }, Q" E
; Note: expecting to be run when the active window is Explorer.% w( L- s. H5 q5 P: w B+ a
;
$ k6 G N* S* N! H8 r- C0 o+ W OpenCmdInCurrent()
7 A, s3 T1 Z0 H/ X$ @& i+ y {
) d$ S, U; w3 i: f: l) J* a# m6 m f! \ ; This is required to get the full path of the file from the address bar
/ m0 Z+ w6 K% H8 r WinGetText, full_path, A
0 k* P. V& F8 E/ S6 m ; Split on newline (`n) u/ m9 \' L1 E3 x
StringSplit, word_array, full_path, `n. X! L# g s4 T: J! P5 J
; Take the first element from the array
' e4 b) P. C* C) @; N$ d& C full_path = %word_array1%4 W6 d/ ^) u! n4 [* J: o, X1 M
; strip to bare address: u) M* U' a* R4 |/ T4 P
full_path := RegExReplace(full_path, “地址: “, “”)+ h- i8 h$ Q8 n7 j
; Just in case – remove all carriage returns (`r)
/ X' O5 }' h! y1 K. ^ StringReplace, full_path, full_path, `r, , all
1 N* x! Z: e3 M! d* r1 w( @ IfInString full_path, \
6 r$ I6 v- Y! R1 Z {
* d# `2 t" t( C! Q Run, cmd /K cd /D “%full_path%”- P" r% |! V% s m, {# {
}# L/ d# ] Q2 r- V7 ^! h5 @& l
else
! K( b6 `; x$ Z {! |% M' O0 \ t% U! E+ D
Run, cmd /K cd /D “C:\ ”& x( L% Z4 m) h
}4 i1 D* R6 W* o! t! m6 K) O
}
! w9 y; D- _9 U3 f& } 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
- }" K4 a) A; v( R) |. p 这段小代码肯能有两个你需要修改的地方. m! a) o0 Y; c
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键) x2 F% b2 ~. ~; Q, N0 S
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “/ L, ` I, }! \& ^1 r
|