此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。+ m- e' {) R8 r$ ?! N
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
8 \# }! [9 X7 k6 B8 \( R1 b 方式一:
- I/ j/ n. A4 I- f) ~; v# [ 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
1 b- W, T2 O3 L, h3 y. o 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
5 a, `, X$ x4 y5 Z3 B HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。8 W: G0 T4 ^0 c; M' g1 |
方式二:: P" x) ^ K/ @. B! [8 k
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
4 Y8 L! b: t, n, i- w6 O1 O7 T6 M SetTitleMatchMode RegEx! s5 U' E- H4 f9 n, y
return
) M# y# c" r6 w. W) j ; Stuff to do when Windows Explorer is open- T$ M1 {1 J- K( r$ `
;. `) o6 `( [+ \, }7 q2 y! ]
#IfWinActive ahk_class ExploreWClass|CabinetWClass2 n7 `+ g& A Y3 J" B7 E" g% `! D" B6 P
; open ‘cmd’ in the current directory0 y* Y3 S: c" v5 e
;
# ?6 G) X+ O! K' q) y #c::
- W6 K: H- Y4 s1 n- H; N- F6 A8 F OpenCmdInCurrent()! X2 J) }$ t4 `6 J% q
return1 V& S$ \: C; v9 ~& @2 w
#IfWinActive3 r9 G x$ ]9 h& i, H2 x
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.8 _( I- `2 C! |. B8 ?0 S" e) d
; Note: expecting to be run when the active window is Explorer.. q' G9 |/ n3 a
;! V0 o5 y% v7 [0 I$ ]2 N+ k' Z1 o
OpenCmdInCurrent()6 d! V; p; Y1 ]7 [2 Y( }
{% C2 X& M5 Q1 o0 s. I
; This is required to get the full path of the file from the address bar* O$ i( Y7 z5 G6 f4 O$ f- n9 }2 w
WinGetText, full_path, A
3 E3 [1 r3 ]- w5 G3 N ; Split on newline (`n)
: o4 A0 i) `1 Z% E StringSplit, word_array, full_path, `n- A# p8 g5 w" d3 |) L% _* p! n* _
; Take the first element from the array
4 }' r: m' w* |* K full_path = %word_array1%
+ r7 v0 t: h( h ; strip to bare address% Q& Q$ B6 X5 g3 f) I, [- V* K
full_path := RegExReplace(full_path, “地址: “, “”)
. E: R/ S( C: e, \3 L ; Just in case – remove all carriage returns (`r)
2 |/ ^/ ~0 B, S1 Q2 q StringReplace, full_path, full_path, `r, , all2 n! j$ I* l/ t* S
IfInString full_path, \
' u# y2 C! t! a! Z$ ~# _ {
* @, }9 Z: \+ e0 X/ j. I; O Run, cmd /K cd /D “%full_path%”
& ?3 v% B/ G) \ }6 I, O3 w' M- E* E' R/ L
else
( A0 S; }, p* o3 R9 ] {8 f- m5 o) @$ `! w8 H- t5 x
Run, cmd /K cd /D “C:\ ”1 u% n7 M* c7 H
} p$ d, n& m7 J R, H& N9 t2 L
}% y$ m, g: d5 n; v! y0 x5 b
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
j, D7 }2 E0 y+ _9 B3 N3 p 这段小代码肯能有两个你需要修改的地方
) G# ?; V/ P, e# j$ ~; o 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键) o% d2 h( A3 J# q4 ~( w
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
; w* B4 \' f6 d! ~- a" H7 s- O |