此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。8 k, F D( f u3 t# I$ c
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。) M# H; s0 a9 v2 l
方式一:4 b) H+ @; z& `7 Q3 P! p
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
. x& `) Z4 n7 j9 r! i' R" g/ Y 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
5 v9 m- h* u: q: _ HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
( ?2 s0 t, l6 `) E/ p 方式二:
& ~2 i5 j, ]; [2 M& w0 g9 v 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下: N! g6 ~% F% d+ ?
SetTitleMatchMode RegEx
" c$ s9 ]5 d/ l( T, S9 h return
' r: V& W) z8 s; e& Y3 _ ; Stuff to do when Windows Explorer is open
! Y4 ]3 t' z7 F' m: N# p ;
9 v% }. X+ y5 m" K! C #IfWinActive ahk_class ExploreWClass|CabinetWClass3 {5 K( D+ Y' V* R0 h: a) I
; open ‘cmd’ in the current directory3 `: M8 J5 Y3 `
;
, J6 f) `3 v4 S5 J7 ]9 d! n #c::: q; E) G1 k. X) \* @; r5 q- ]
OpenCmdInCurrent(). T. C6 D0 h6 l2 s
return
% H3 }) M e2 C7 e2 D- } #IfWinActive
* S" N; [% X6 `# N& } ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.0 A$ ]; Z& F; Z# d
; Note: expecting to be run when the active window is Explorer.
6 M5 d/ k0 V" N. f& y( ~ j ;
# O7 ?' |& j" F" \. B: m4 X OpenCmdInCurrent()9 O* X8 v' h4 `# O/ T+ |- y
{
; t9 Z; n, x" }' w, t( P' s* Q ; This is required to get the full path of the file from the address bar
$ i" T" }: _7 J1 [, V! n m/ y WinGetText, full_path, A5 b4 M" c! X: S
; Split on newline (`n)7 U1 q# l6 t1 M+ c
StringSplit, word_array, full_path, `n% F8 G' w1 Y$ N; T3 a0 J
; Take the first element from the array
( |: v5 V! o; B+ O* R& f. j full_path = %word_array1%
3 K: k: }9 [, X! p8 Q ; strip to bare address+ H& {* Q4 Y) ^
full_path := RegExReplace(full_path, “地址: “, “”)
2 X# a/ ?) @1 K! ` ; Just in case – remove all carriage returns (`r)7 t) w* o+ Z/ g: O$ T- }
StringReplace, full_path, full_path, `r, , all7 ^* {+ K' {: W+ E4 c: u1 [
IfInString full_path, \2 L' y! M8 |( D0 ^/ C7 n! K+ u
{: ?8 `1 v/ o' a& P
Run, cmd /K cd /D “%full_path%”' V7 F9 [8 B0 R+ z
}
# s! U$ _- h' K7 u1 V else w( {. e; A; J) K
{
' ^8 o4 N' U3 q9 b! q p+ X+ _! [ Run, cmd /K cd /D “C:\ ”
) |$ D: A4 X# L! W5 [, `- X }' w5 k% Z0 ~4 ]. J6 g- C& R9 D( Y4 ^- j
}) a# l) l- h. d
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。5 Z' f; @" b/ ]
这段小代码肯能有两个你需要修改的地方" i# \; N w9 t9 W9 @/ g! J; v
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键7 `5 V# }/ {" \, Z9 D3 j5 O
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “1 B$ O1 c$ [, T5 ^
|