此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。4 N( X ~4 m- t x7 F# o, |
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。" X' d- m- u6 y4 W B. G7 x
方式一:
/ V3 j. b+ _- S" n4 G# R8 M7 N) O 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
1 o# p1 I! @8 ^& t3 f" E! { 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
4 S) r) {6 m# l2 ~$ Y' Q) l3 Y) o HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
# U0 m o5 {# M/ ~" q9 D 方式二:/ C# |3 n2 R4 B5 H& A" n7 I
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:2 `3 R3 q* ^; i. d1 n; {
SetTitleMatchMode RegEx3 i7 ^2 u+ _7 `1 Y; V
return- Y3 N. P. W% Q) {% n
; Stuff to do when Windows Explorer is open5 ? p8 f; l* V( `5 s1 j' }: t t* A
;8 b3 O6 M- c' [" d: a2 d! b
#IfWinActive ahk_class ExploreWClass|CabinetWClass
* W; [ ?# l" d ; open ‘cmd’ in the current directory
1 I- s1 }' T8 X ;/ M" @' O7 m8 F6 |
#c::
/ a3 y9 A |6 [' T6 a& } OpenCmdInCurrent()
) q7 A5 H4 u9 {+ j2 I: R7 a return5 x5 f* Z: ?' b5 X7 b1 D
#IfWinActive
9 u4 _: x. z3 w1 K% Z ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.' X3 _" s$ g7 F: {* ?
; Note: expecting to be run when the active window is Explorer.% t: `( Z! B9 U# P5 k1 ^2 t5 H: [
;" X8 f0 U# o) ^& R
OpenCmdInCurrent()
2 e# M' x. X+ e E {
3 h: F& D/ `% f! Z ; This is required to get the full path of the file from the address bar* L# Q: s0 w3 K+ {
WinGetText, full_path, A
3 Z; j$ F! u4 m3 d$ t ; Split on newline (`n)) t/ @: f6 L( h2 C( S: a7 T! O: Z) R% \
StringSplit, word_array, full_path, `n
! F/ [4 F! I* s5 y4 n ; Take the first element from the array' [+ V* T# [" _ u
full_path = %word_array1%
% Y5 s7 R' }: F1 w( a1 c$ }) m3 Z8 y ; strip to bare address. O" |2 F3 u2 i9 E+ Z
full_path := RegExReplace(full_path, “地址: “, “”)7 m& m7 b* b0 F1 S7 @6 V' X
; Just in case – remove all carriage returns (`r)
9 A- d9 q8 t; x- O: E4 L StringReplace, full_path, full_path, `r, , all# m# i- I5 {9 W. |- Y T5 |
IfInString full_path, \) ?3 w5 q- D0 E; L0 x% n* Y5 P& Q
{
/ S* z# D& O9 z& s p$ [ Run, cmd /K cd /D “%full_path%”1 Y; n! a9 f$ _& S" n
}
- A) d) J& S% J else" C2 W8 T, w& P/ h8 w
{# w3 l x" U; V$ p1 g
Run, cmd /K cd /D “C:\ ”
- @) k% ^6 a0 }6 K/ S1 u }
8 u/ r) r0 m, f* W" t8 a7 u: N# \ }
8 H4 r+ A# r9 c; v @( L) G 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。/ e/ I8 [7 N6 w( F9 q4 g# x
这段小代码肯能有两个你需要修改的地方
$ O" U" T% s. U3 e8 u) d2 s2 x% u 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
# A% ^* e" G- W& s# Q 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “7 K( J' v# @9 e
|