此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
1 B: z5 @: t$ G/ x3 r' n/ {! V 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
- ~2 j, }, }+ O' ~+ Y- j 方式一:
: \* l, w6 g- I' l9 g 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,% t0 N- P5 e& p: i i1 l
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和6 ?' W! ^% J4 @ A j
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。0 a6 {# Z% `( V: |8 B2 _
方式二:
- J& H2 M `" m8 X$ ]& X9 W5 P 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:# c8 J8 s3 Y H( o* K$ P
SetTitleMatchMode RegEx
8 t7 t9 ~7 W! X0 j return4 s) H, E/ C7 \; e4 W
; Stuff to do when Windows Explorer is open
6 {; f4 W# ?% g- ^, ]$ q5 i3 | ;
5 O! I: S5 i; N' C' \ #IfWinActive ahk_class ExploreWClass|CabinetWClass
% _9 Q# ?* @0 `0 | ; open ‘cmd’ in the current directory
2 H1 ~ u% ?5 o% \ L6 I- E ;
- A- a* q7 m' g' g, s #c::# M& o$ q/ o, X: c$ }
OpenCmdInCurrent()% h" o+ C" k' I
return
3 K. j& d1 ?& \) m9 D8 o #IfWinActive2 s9 K- K( g) i3 a* {
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.. J% i* G8 H3 u$ i4 M* Z
; Note: expecting to be run when the active window is Explorer.
) d: {4 {% q# @; B$ V ;* x% C( K$ `7 j
OpenCmdInCurrent()
8 l3 J7 i# ]4 N+ H9 o& w) t$ U) ~ {
5 R$ q5 l) n2 P7 l) J7 b6 O4 D% I ; This is required to get the full path of the file from the address bar! X6 @' X7 p5 S' ~. z0 `6 i& Q K
WinGetText, full_path, A- L" V! E( T: v! O5 ]) N" F
; Split on newline (`n)
/ ?4 p) l. Z% L1 u, t6 i/ H+ V StringSplit, word_array, full_path, `n
5 L* v8 e/ l( i/ J. r* q" z ; Take the first element from the array! @% ]/ ^$ v+ V* p1 X( S' |
full_path = %word_array1%
) C5 s2 e# E2 R+ W8 v ; strip to bare address
; y9 j# u, k5 U: V; W: C/ P full_path := RegExReplace(full_path, “地址: “, “”)
1 _" P8 M: o; p% i8 a \4 G, V ; Just in case – remove all carriage returns (`r)
4 g' E% V/ w8 @1 X' {5 x' | StringReplace, full_path, full_path, `r, , all6 k0 _) h+ {8 t3 G8 Z' [& }- P
IfInString full_path, \0 o5 p$ o! b$ a4 H3 L5 S( }" Q% v& ]
{
, s9 A0 O$ _: s! u; h Run, cmd /K cd /D “%full_path%”; C* I. @7 y* k8 E
}, I3 C( ~& b8 L
else
* i6 K* Z; e( M5 L. { {; G6 Q: s6 s/ O* b6 S5 ]# d/ L
Run, cmd /K cd /D “C:\ ”0 @ ]2 i, ]. Q' R- f) R
}, W8 t% z2 o* B. T& |5 Q
}5 S* ~' P3 n- s- |
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
5 o* l! u4 ^; r: S) p/ S* k ]8 A 这段小代码肯能有两个你需要修改的地方
" Q+ J8 m0 Q' O" S/ t% E: c) V 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键* S, g% L! ~' Q5 | d1 f& ?
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “& `- [0 W! V. B. c) w' j% n
|