此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
8 }8 Q! V. B% o# h* Y# u 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。; H0 B% t! G$ @( e% v& P
方式一:6 q% y1 z7 k9 }' U; k
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,; \7 d8 M) P' _
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和7 [" ] E/ u, p5 b
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
) M6 S( ?0 L" b( s 方式二:
0 r3 N$ b! ?' Z& L, [ 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:0 y3 P; _( p4 h5 t6 {: t6 U
SetTitleMatchMode RegEx
# s# |+ H, l# J, s) ?+ @ return8 q9 h0 O9 z' r; [& u: K
; Stuff to do when Windows Explorer is open" m0 G5 @7 `4 X- [4 W) Z
;) x# j8 | @3 u: o2 W
#IfWinActive ahk_class ExploreWClass|CabinetWClass9 N1 _3 }) U/ x3 f( |! d
; open ‘cmd’ in the current directory
) y$ m9 t' U2 H! {# v ;
. o# u+ E6 c+ C& ]2 O #c::
, J! u: `1 [7 E) O* a9 H2 b& v OpenCmdInCurrent() h. l, B! m0 x- r
return; z- g) {5 E! j+ v
#IfWinActive* \& c& \: ]( u1 B0 i% r* j# q
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.; p( E" n/ A* v; D* Q( a- Z
; Note: expecting to be run when the active window is Explorer.. d% z6 p r" o& d2 }5 K' _* A
;
: d4 K) y) |2 P7 P5 f3 U OpenCmdInCurrent()8 ~: P( Z2 @- m, [' u9 j
{! |0 r, H/ O) G; H: J
; This is required to get the full path of the file from the address bar
/ s4 o7 i4 J& B: T) [ WinGetText, full_path, A
' @+ x* R8 j8 S! i: g6 U" A4 E ; Split on newline (`n)
% S3 T4 g3 w6 e, p StringSplit, word_array, full_path, `n
0 b+ R6 F7 A: ^1 T5 m1 L/ z ; Take the first element from the array
! P; r/ {9 R. ?8 L; D full_path = %word_array1%. H: D8 f4 [0 }
; strip to bare address
8 M9 Q0 n) f, L# [; @8 q full_path := RegExReplace(full_path, “地址: “, “”)) \5 P: f; C8 N4 y2 `9 X, t! d
; Just in case – remove all carriage returns (`r)/ N1 D5 ?0 y# l6 D. D3 u% C' F
StringReplace, full_path, full_path, `r, , all
6 W8 y2 q0 V/ `& N/ f1 P5 l) l IfInString full_path, \
; l2 Z5 a* O+ N. W3 r+ ? {8 F5 c2 `6 ]! J% A5 ?7 }+ m8 C5 ^+ {
Run, cmd /K cd /D “%full_path%”
9 D0 ?; G8 q. p! H1 e/ e/ Y }0 g- \, Q7 J, Q3 t
else$ B3 U' k0 r9 e4 H6 z
{
+ h5 f( N- Y U, F2 h9 z) Q+ b/ C" J Run, cmd /K cd /D “C:\ ”4 m' b# q. [5 ~ d5 T( o4 p
}
" f( b% R/ D3 N# y# D; y6 V7 o }1 b9 O( \) O, ?( {$ h
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。: ?- B+ |9 H: y0 P- k
这段小代码肯能有两个你需要修改的地方
8 L. ~3 ?: w0 [# b 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键# Y7 {% b- Z- m6 x' p6 S
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
: A7 y, \ }! L- e. g* I) s |