此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
( U8 _. P( L3 }" K. j1 e+ F! _ 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。# Q4 Q q" m& u/ E# h" E9 Z
方式一:4 |4 ?! j" D k$ j& A$ I* S
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,8 O% A( l3 ~1 d; [% r$ Z
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和! W: G7 w0 t/ L7 f, x
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。3 h. t" y- ~3 d$ ~/ `3 e8 L
方式二:* T3 L* F# y& q; i ?
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:9 g7 V( o$ Y4 `8 h0 j) y
SetTitleMatchMode RegEx
/ D) V' R% @+ {% g9 V: c; c5 N return6 W+ t/ h! u5 x9 E
; Stuff to do when Windows Explorer is open6 V: U c) r9 V* G8 D2 D
;5 v6 o2 M* z2 c8 M2 i U; q( ^; \, k6 T
#IfWinActive ahk_class ExploreWClass|CabinetWClass9 I) |/ p" ~: U# w% F+ ?
; open ‘cmd’ in the current directory
2 Z) i+ a; p0 U( Y8 R5 ~+ U ;& V) v4 u9 L3 _+ p9 ~
#c::$ S! h, l! ?8 T; H
OpenCmdInCurrent()
2 P g" F" f3 v return
3 k9 n+ G; _1 l #IfWinActive
5 v n* T; Q8 \- E3 x5 S( l! N* r ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.4 E7 c' I+ \! X! ~- r
; Note: expecting to be run when the active window is Explorer.; U$ d% _; H6 f, p/ O* r5 c1 s
;
* g, y" Z! O6 _ OpenCmdInCurrent()
) {: h( F+ q# x+ y W {
' y9 }4 H1 b7 i; S ; This is required to get the full path of the file from the address bar/ M$ l& h5 q$ [- `' a" w, g
WinGetText, full_path, A
7 D B2 U( a6 ]! E/ \ ; Split on newline (`n)
- o8 J, r: C1 l" O, y StringSplit, word_array, full_path, `n
$ k5 D5 U: l" I. G9 Z( d5 i ; Take the first element from the array2 @- f/ o8 ?$ U
full_path = %word_array1%: z& M v* A6 `" a
; strip to bare address) ^0 l6 V X& w" h
full_path := RegExReplace(full_path, “地址: “, “”)
: ?' P1 B' j* m0 n6 h8 {) q9 v ; Just in case – remove all carriage returns (`r)% J: C1 ^" i2 K8 _& r/ `+ q, s
StringReplace, full_path, full_path, `r, , all# _. M" N) b" O5 x1 {
IfInString full_path, \
3 R1 G7 f8 R! B. W% v {
* ], w+ J5 ^2 A: D3 u; }6 z1 {4 @" W Run, cmd /K cd /D “%full_path%”
C ?7 o. a1 J' v }: f/ @; J, ]# p5 Z
else
, E; {/ Y4 t. j6 V( C M {; O. |9 p1 I& r3 D
Run, cmd /K cd /D “C:\ ”
# u; G* v8 l: |& @8 P }
3 E( A: O0 G" x4 j+ F }& i/ h- `) o) r4 P3 i, o
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
r- A8 W' ^+ c" c {& _$ y: B 这段小代码肯能有两个你需要修改的地方. n4 D4 Y3 @+ E
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键; ?$ G& R4 I) v
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
; P+ G: ~ l. g% G |