此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
5 P# l/ R/ {; k# `3 r4 U8 t 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。- {% I- u0 F; w# M* |1 u
方式一:
. R9 g, K+ `: N! b/ K/ E 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
$ i) I( ~* t6 z) \$ n. P# F 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和( y. p4 o1 k; K! ^. u9 Y7 G
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。8 m) s9 N5 \& q) }
方式二:
: G2 I) X7 J) ?. G# f 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
8 ~9 o3 h' @) S5 q+ H; [ SetTitleMatchMode RegEx
0 q+ n# A! r# L6 `8 f" e return
# |8 Q6 f h- S ; Stuff to do when Windows Explorer is open T. J! S1 L& K: E0 Q$ ^
;
# U" y" I$ H+ {' O #IfWinActive ahk_class ExploreWClass|CabinetWClass" _+ c% o* E% h" f6 O: B8 `# y
; open ‘cmd’ in the current directory) @( H$ v _ `; [6 M3 `9 h5 P% Y
;! @1 L4 B, b: m- @5 b, m9 W3 l
#c::
4 p; a% s$ a3 k. R8 Z- {' [ OpenCmdInCurrent()' x% R w8 a6 l3 Y- e: h9 z
return$ Q, o: a6 K& B. w4 I& b# Y# |# h: p
#IfWinActive ^, L5 e7 M9 {2 |6 e( h8 t, M
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.; g$ }7 j9 g% q1 l& N0 i
; Note: expecting to be run when the active window is Explorer.
- L) G2 B* z' G6 h ;& V& R$ B9 g2 ^& }1 `9 ~3 f H
OpenCmdInCurrent()
& q) }6 H7 h, e {
; p9 l$ O( f4 D5 ?7 X! z ; This is required to get the full path of the file from the address bar$ u# z+ K. P/ i; o
WinGetText, full_path, A' f3 ~8 g) h' G
; Split on newline (`n)% E `" K7 ?( u" y+ ?! l, }
StringSplit, word_array, full_path, `n% ^9 I4 P, e3 ]
; Take the first element from the array
% J- _, \5 | Q full_path = %word_array1%
0 K1 P$ p# B0 G4 ~( z ; strip to bare address- X3 D% E. @' D* E/ {3 H/ ]9 F
full_path := RegExReplace(full_path, “地址: “, “”)3 F* V$ h% f: ^- y( o- n3 o0 K
; Just in case – remove all carriage returns (`r)
/ O) N- T/ x$ q+ w5 `. Y& ?5 t' s c StringReplace, full_path, full_path, `r, , all
0 Q" e, E/ P: J! U# j. s0 E IfInString full_path, \9 Z/ X; O. H- e& _; |
{! k. D. ]% q& S; [+ J s
Run, cmd /K cd /D “%full_path%”
3 `3 [3 Q8 `2 \" D* | }8 h. f, F. C, d; X7 h
else- p. ]1 `% f2 u* o% V3 |, L
{
; e) l0 ?( }4 N" {2 h. A# Z i Run, cmd /K cd /D “C:\ ”, Q2 T7 E) ~5 Q# b9 C6 V
}
B; ?1 u$ s3 z8 N+ R# h }
' T7 t& h6 {) t5 E+ j! ]9 | 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。7 A; v) [% b# \0 E
这段小代码肯能有两个你需要修改的地方
2 h, j& H# V# ]* o' | 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键: N( x( L/ J( o3 E$ u' h
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “5 q5 T2 f4 l1 ]+ B( h
|