此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。% M% m5 ~6 B, F" A' j# Y6 r4 X
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。$ f7 L0 U7 R( N7 {) S' R' m5 s8 {- y8 t
方式一:. H+ F) l3 h) z: g
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
; i+ _( W9 ]2 g6 j7 j; ?: R' T& x4 b 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和3 ]/ [- q( S: {
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
3 w% p' M- p6 I- e; u 方式二:3 v1 S! x: e( W3 J9 b2 _7 c u* L# B
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:1 H3 I* }3 T. Q
SetTitleMatchMode RegEx
" D: T: }+ n7 S3 S; G return
3 ~4 e, H7 P, e- Q4 `9 s1 d, Q3 D ; Stuff to do when Windows Explorer is open
2 Y9 u9 c/ E& W/ h% N2 U* b: K ;
$ j8 _/ T6 n- a5 j #IfWinActive ahk_class ExploreWClass|CabinetWClass* d$ [8 T) G. Y
; open ‘cmd’ in the current directory
! t- l- Q/ B2 }/ d6 P+ b9 ]; ^1 F ;! O7 X$ w) }4 T, }0 p& a
#c::
8 d4 w6 N' x) J" U9 _ OpenCmdInCurrent()% G& ~! c4 \9 D# ~0 B
return4 I$ X- h- _: ~& t j8 L3 y
#IfWinActive
) E6 C2 B% q Q. p, B ; Opens the command shell ‘cmd’ in the directory browsed in Explorer. E. V- i' \$ T: E. P) }% e: ^" n I
; Note: expecting to be run when the active window is Explorer. C4 g& ~ M; v; L
;
( X& V6 j2 n# D( n4 D OpenCmdInCurrent()' I; t e& W$ I5 P
{
. y- l' G& n0 E! H* ~ ; This is required to get the full path of the file from the address bar) H# S F4 A: V S' p! j
WinGetText, full_path, A- N" K3 s: o6 z% V9 W* e
; Split on newline (`n)8 b, \; x# O4 G0 B1 c: S6 R& y1 T( C
StringSplit, word_array, full_path, `n
* y6 \) ^0 S/ ~+ W3 |: \1 ^ ; Take the first element from the array
8 L+ d% h4 v% h4 e. p full_path = %word_array1%
" u5 C* j. ]4 W9 J ; strip to bare address
/ e4 w% B0 \/ |4 K5 S' y! p) W full_path := RegExReplace(full_path, “地址: “, “”)2 y) n2 E: E7 |" R! H
; Just in case – remove all carriage returns (`r)8 n2 Y) _ E7 o- h- v
StringReplace, full_path, full_path, `r, , all# \9 R1 y( p, ]% ~. L' q1 \
IfInString full_path, \) ^0 Y( K" |- S9 N
{
3 m3 O0 K7 D0 b3 V* g# C Run, cmd /K cd /D “%full_path%”. M1 Q% _( E- J9 l( m/ d
}
& x1 a! U" }, L8 N( B2 U" a6 N% u7 N else8 K) I# c: z& C& ~. u; A. `/ A
{
/ k- l6 c, ~' G- s0 o* \7 x Run, cmd /K cd /D “C:\ ”& ~3 ?8 j# _3 d1 O! y g& {
}
# R6 z2 ?6 F4 h# @ }
, _. \6 `% I% q3 X) ] 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。 h; o0 \" X" M: R
这段小代码肯能有两个你需要修改的地方/ b/ A$ j4 U# {% D4 q
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键. E. V8 w: U. M( b L& f) K" u
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
" N* g( ]/ u, F6 y8 j3 y0 A# n D |