此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。! ~; s' C5 |8 d0 h; B1 F
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。8 Q$ `& A: b- v8 m! Z
方式一:$ ~/ g/ a1 Z+ s% {0 ~/ f @6 ?) e* C/ `
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
" c9 q2 f0 d$ l* l 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
5 G6 ?, v7 P# V HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
, M6 h1 F* }# P7 i 方式二:5 k# p+ H2 Y4 E Y: A
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:9 M$ W# W5 L7 k, S5 o' J
SetTitleMatchMode RegEx
0 Y( r$ }4 X0 U) w3 H return6 I, t$ O, z" N3 ^* ^( f
; Stuff to do when Windows Explorer is open) \$ y8 K! O9 t/ P, F# P. _
;
/ V' G5 t. H$ |3 O7 g4 A #IfWinActive ahk_class ExploreWClass|CabinetWClass" K" d' L" S' X9 P( C
; open ‘cmd’ in the current directory, C. |7 V' L/ r. b8 J5 K
;
0 m, p# J, R3 h! j' d: R& L7 B& y #c::1 a3 N$ y- M& F" l5 X" p
OpenCmdInCurrent()' y8 E9 k/ s; t& W
return* n ^8 C7 ?& c5 E
#IfWinActive
$ v( D% W. j" `" b" s ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
) B8 P% i& |2 E5 N" ~ ; Note: expecting to be run when the active window is Explorer.
# ?; ?. D) B+ ~/ `6 D0 L1 j: R) J6 ^ ;
5 W) F- l, G, {6 N4 X) s# J3 X! N OpenCmdInCurrent()) p, T$ _9 D6 t0 ^
{6 x8 D$ B( {5 ~6 t- [6 N5 t6 S, z
; This is required to get the full path of the file from the address bar1 A! V0 ?4 ^5 q4 f1 t, S
WinGetText, full_path, A' f" i, c! H4 o7 G9 [* @( w
; Split on newline (`n)3 o% f. w5 D" h( O4 D8 C- I# P$ u6 R
StringSplit, word_array, full_path, `n' Z5 Q: y9 R7 f. v+ B% g
; Take the first element from the array
, K0 S* _# d# M% [2 i full_path = %word_array1%, B/ w; Q' d s5 j) J0 @
; strip to bare address: W5 j) n! s/ E' x7 Z2 J
full_path := RegExReplace(full_path, “地址: “, “”)- v" e. @& m% ]& q0 Y/ c4 @5 I
; Just in case – remove all carriage returns (`r) D5 o$ L6 o8 S; R
StringReplace, full_path, full_path, `r, , all9 T- n- W4 {, g0 e+ E0 D
IfInString full_path, \
: _/ r3 n: @9 [4 d {
' @( U; t' F! v4 M, e3 x7 b+ m3 Y Run, cmd /K cd /D “%full_path%”5 @' d3 Y$ C8 B9 ]
}
' d+ G5 f. B) p# h; h$ y else
' z) [* a* b' E {1 U2 ~$ O' V$ u9 ]
Run, cmd /K cd /D “C:\ ”' e/ S# m. k- P
}- Z: L9 Z7 V. Y, |- o& b- o, L3 C# j
}
5 ^, M- }% @% h$ b" i. N( ~ 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。+ u6 x/ g e! L1 Y _9 S6 s
这段小代码肯能有两个你需要修改的地方1 ?0 p0 e2 d& R' e1 \, R4 t6 f
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
/ L& s4 ?& ?' z1 j& i2 C5 L 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
, m4 s n" C4 O% u2 O |