此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。2 c' B, ?: c: U$ P8 h& Q3 ~9 y
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。# P h! i, T2 a6 }" G* Q
方式一:& ~" C' \! Q2 p( d* q# ]# i `
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
2 N3 w" h9 C/ v4 k 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和0 U. A( h: Q: l
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
; |0 e; J3 }8 ?; v8 A$ A 方式二:, t7 E0 n- P( ]2 y1 W
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:* @/ I9 @ M7 q$ f
SetTitleMatchMode RegEx3 e# O; ~5 x/ C
return
& h) z i$ p" H# o ; Stuff to do when Windows Explorer is open3 O0 y, k# ]' S" F( ?, \
;
1 e* y5 X# k! t7 ^0 D6 z) F. r #IfWinActive ahk_class ExploreWClass|CabinetWClass) G% a+ R. l x* ^
; open ‘cmd’ in the current directory8 O6 A/ R* ~" \
;1 h& m/ O* d/ R1 S! i
#c::
& `" G- u2 @! v( {0 s6 M OpenCmdInCurrent(): B' F, ]/ F$ ~, M3 r
return/ ^) J8 l5 k' n6 S3 E
#IfWinActive. H3 \ S& v6 g' _
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
3 h' Q# v! e4 D- v$ N% K/ N ; Note: expecting to be run when the active window is Explorer.
; |% u0 x" P; [6 m7 R+ f( e, C+ { ;
# X! w' k" q2 A: n OpenCmdInCurrent(), l6 \5 J. c h3 y" v6 O7 X% ^' G
{
3 s/ R: i: B7 o% ~% l ; This is required to get the full path of the file from the address bar
3 {8 ~( T- b8 b: t* e7 x9 _, x1 r WinGetText, full_path, A
% K1 u" O6 l4 N8 N. L. B/ b ; Split on newline (`n)$ X9 `1 d8 z. D5 S
StringSplit, word_array, full_path, `n) C6 w. Y% } [7 x# R
; Take the first element from the array
) b) f8 ^" }+ A8 a# a6 W, l% }7 @0 N full_path = %word_array1%
' C! N& c3 }4 Y6 n, C7 Y ; strip to bare address
2 D! j7 o# Z9 T full_path := RegExReplace(full_path, “地址: “, “”)& t4 U3 k5 m) E( C8 l* L
; Just in case – remove all carriage returns (`r)
) `& I+ x* S# e; l8 P# [) ^! \ StringReplace, full_path, full_path, `r, , all
& v8 }% `* b' B, f IfInString full_path, \- ]/ w5 m* l! N
{9 K. ?. [* M2 y2 V+ w
Run, cmd /K cd /D “%full_path%”* h: l6 t; }& Y! X
}
/ m. {- G8 s$ p else& z+ a9 @& W+ ^ L4 E, F# T! v$ Z0 E @
{' V" S0 W4 q) `
Run, cmd /K cd /D “C:\ ”
$ y2 I2 w: e! f0 H1 Z! G* m3 S& a }
4 B0 D- B- a& |& C! G1 l$ u" z3 e# s }9 l+ X' M6 v6 c/ g. ]. Z
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
* C! D3 G5 @+ m: e7 B 这段小代码肯能有两个你需要修改的地方5 s5 _+ o6 C# c! G" _8 \5 a. J4 T
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
l: F- a; X+ E% O1 ? 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
9 O' }7 @0 V6 s% Y* m |