此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。4 \7 m) `) w4 a
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。- d" Y5 r7 S" k6 y% c6 N
方式一:
b. Q9 V7 }5 v 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,. E7 V$ B5 y' E' u2 D/ g
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
/ H4 E0 s* H3 h$ ^ HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
, N: n5 H8 K+ n 方式二:% _+ K; V! ]9 c. c9 s2 F" U
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
6 J \$ E" l- \/ V" w SetTitleMatchMode RegEx. s4 f+ ?/ J- ~* _9 t
return( h0 ^0 X! o2 I, g, Z; G* m
; Stuff to do when Windows Explorer is open* l7 [) F+ n! ~* G
;1 e7 F: L: }# b' q. n/ Y
#IfWinActive ahk_class ExploreWClass|CabinetWClass5 C9 }6 r, T" A- Y* |
; open ‘cmd’ in the current directory% ?' j4 Z' Z' F. t$ A+ a8 B( k3 {
;1 D+ N6 H, z- J, g/ T0 X
#c::2 q4 ]0 b r z- \+ c4 g, m: L
OpenCmdInCurrent()
' \- S% S+ l' H6 Y+ t return
2 C" Q& |# m* x! n6 e& u) ^5 x7 Y #IfWinActive7 [& ^) x* S, A* D
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
/ l! _( p2 i5 Z. o ; Note: expecting to be run when the active window is Explorer.% R) M; n# p9 p
;
5 {) |! ~& L# X& U OpenCmdInCurrent()- @4 b7 u- c4 @( ]2 k
{0 y' ]3 B1 a: I$ k8 x
; This is required to get the full path of the file from the address bar# `! L- L# j: q$ i( Z. S$ z
WinGetText, full_path, A
; m% S7 P7 F& ?3 J% r/ q! O' V- O ; Split on newline (`n)
% B! t+ ~. j) J% z* J StringSplit, word_array, full_path, `n
6 [9 c: V" u+ C! J$ e" ]. g2 w ; Take the first element from the array! J# f- M7 L/ [+ v: W) @8 s/ D
full_path = %word_array1%
: Y( d0 w6 `9 `. z6 k ; strip to bare address) E& D3 h8 N+ c0 M+ U
full_path := RegExReplace(full_path, “地址: “, “”)
/ O0 l- g, k a6 e& h ; Just in case – remove all carriage returns (`r)# K- @0 j& _+ V% q
StringReplace, full_path, full_path, `r, , all
+ _$ k! p# O$ E& S IfInString full_path, \+ e) m, P5 g" ]; g
{ y2 J2 N( p, _% f
Run, cmd /K cd /D “%full_path%”. x7 B3 d `3 E" P/ A) U4 J }6 R
}
0 v' \) J, A- Y# n' J else
2 o/ h, W4 ~& C& C) \ {
5 ?: j% n9 l$ U. l5 d Run, cmd /K cd /D “C:\ ”6 S1 Q4 d0 H4 w
}2 I, Z E( ]; r
}
6 ]4 ~- I# X7 U% U 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。2 T9 R$ E# }7 Z6 g5 L v
这段小代码肯能有两个你需要修改的地方
' {& U u# h- k, v% l 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
; ?0 }1 H. q4 T+ ?9 u n8 G* a( n 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
1 @1 t, w) `; W) u* T( O0 @/ ^7 Q5 } |