此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
, O: ?4 a3 |* `7 [* A/ `" h 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
0 n* N* \* E8 M( O, `: B 方式一:
2 C/ R% Y# Y& C. z 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,& d5 G# ~9 e. X, z! g
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
; W1 M, j0 U! Q5 R/ y+ w$ | HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。: A' P# Y, ]% A k2 y* Z" F7 _
方式二:+ R+ Y) O6 j6 o$ u& E+ {# k1 e
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:1 w% N7 l( z. c
SetTitleMatchMode RegEx: a$ ~( \6 ]& B2 w! o6 G1 E8 t, `) n) `
return* D* n2 Y* r6 @9 P, ]
; Stuff to do when Windows Explorer is open
. }4 O; k. F5 i: S0 ?# S: E ;
9 h2 q$ P; x/ g #IfWinActive ahk_class ExploreWClass|CabinetWClass
/ V {& B3 x" T7 s& q/ |4 u! n ; open ‘cmd’ in the current directory3 f' m5 P9 D! M
;) N/ B5 v" k& J% `$ f
#c::
+ \1 H% b2 G' R0 \$ \3 a, c OpenCmdInCurrent()7 d/ `( O; @& q3 Y
return
" t# G& ~3 V' T: o #IfWinActive4 U r2 q" ~6 L8 `4 d7 x9 b% J
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.7 }+ H2 V* i, z s0 P0 ?0 \' [
; Note: expecting to be run when the active window is Explorer.6 i0 T5 A) G3 L; q3 K, K
;) D$ j; D3 ^2 e. g
OpenCmdInCurrent()
+ K6 Z; X5 |! X# o: M {
% W4 P0 B% H' s, B. I ; This is required to get the full path of the file from the address bar& ?6 S. p5 C; p$ u+ S, }
WinGetText, full_path, A
0 Z8 y; k6 v" L; p; R2 e8 a ; Split on newline (`n)2 b, j! T( e4 z& A& B3 G
StringSplit, word_array, full_path, `n
8 C4 E1 A& J6 B* ~* P ; Take the first element from the array" E6 q6 j. O8 u7 b
full_path = %word_array1%" A' ?6 A- Z ]9 V4 n( ~
; strip to bare address
7 b }3 z& B' L* L, u4 r7 l ^ full_path := RegExReplace(full_path, “地址: “, “”)
H0 U3 V4 i2 G2 i ; Just in case – remove all carriage returns (`r)% {: m# }5 ]* i5 I' t9 G3 `% H
StringReplace, full_path, full_path, `r, , all! \% _8 c) v3 a1 P7 N0 F# L
IfInString full_path, \. k) V8 i, G* b
{
% p& d: H4 r) ^; T Run, cmd /K cd /D “%full_path%”
: F# g* Y: L: K- o2 W }
% Q7 n# ?4 m; q i- x2 y8 \ else5 h: S6 S+ A- y
{+ n& ~, H" N9 {% f
Run, cmd /K cd /D “C:\ ”/ a) }, y" ^- y0 r6 G( i/ A' p8 J/ f
}* e9 g1 _! J" Q- k/ p6 N
}
3 Y2 D4 h& D! E" j( U* j5 y( k7 h r 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
7 M0 s" Y9 ~% C `2 e- v! Q 这段小代码肯能有两个你需要修改的地方6 H1 W. U+ x: w8 c& m. n
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
* X8 _, n5 f, \! V+ ?/ n 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
& z: l5 Q9 L8 |' [3 W. p" t |