此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
' m T% X) I9 z& z: J7 Q 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
+ s J' t* x! o2 I. R+ ^* l, b+ c 方式一:; X6 s8 {! s# [. N% C, s
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
+ H! t; H$ r& e7 V 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和) ?3 g1 x% _+ C; o7 C
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
' J5 c* _" H) @8 b% M 方式二:% \7 H& X6 y7 P; {$ F
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
/ y. i* @) ?8 z) s) E SetTitleMatchMode RegEx
, e$ N, V: S( G4 U. u' T. f2 e return* z6 G% }0 v/ Q9 e; B; ^
; Stuff to do when Windows Explorer is open+ S8 A# T- P) f; ]( u' I
;6 E$ S0 \- N4 W% X7 |6 p& Z
#IfWinActive ahk_class ExploreWClass|CabinetWClass
1 l5 S5 c4 u9 T! V ; open ‘cmd’ in the current directory: l- }; @5 Q$ C5 L: l T
;
( b! P# S! ^3 L( d- I! K; V #c::
, z3 p; |/ B! p OpenCmdInCurrent(). S$ m! n% Y6 J' x' o: C% E4 H
return
, D! `% p" \! {: ~( ^4 l #IfWinActive
0 A( v: D5 F, X4 E ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
$ ]& C( ?5 x6 y l ; Note: expecting to be run when the active window is Explorer.
2 y# _7 j; C: e1 w5 \* _ ;
9 D- x0 ?4 e& S: f* W OpenCmdInCurrent()# z! z; ^- M. q+ O( _9 R& G. i/ E* L6 i
{# S" A1 u( w) n9 A' J
; This is required to get the full path of the file from the address bar7 D" b3 _/ d! ~/ H; n
WinGetText, full_path, A4 X0 l0 |! s* \' m: D
; Split on newline (`n)
5 M, `. n6 \6 t* o$ y5 [+ y, L- c- \; \ StringSplit, word_array, full_path, `n: f( ?; | W v5 _9 f
; Take the first element from the array5 Z: d/ v6 z/ e8 }
full_path = %word_array1%: x$ K% B& G: n* o
; strip to bare address/ J+ S" L& c/ H, D5 x
full_path := RegExReplace(full_path, “地址: “, “”)
9 x) H% v7 e8 k- v ; Just in case – remove all carriage returns (`r)
% D' ~4 b" s3 L# o9 \3 Y, K! z! _ StringReplace, full_path, full_path, `r, , all: M* B9 w) o# R5 e
IfInString full_path, \8 T9 y+ Q: e7 r% u) m) M& G
{7 h7 U- Q0 k) Q4 b, d$ z( J; F
Run, cmd /K cd /D “%full_path%”: t0 f% w) ~* x3 A; v, |. C8 g/ \
}5 L: R3 O/ A* x5 X3 [
else
$ ]/ {7 }4 U/ _/ D0 N {
3 Q8 u2 s# E4 m n" ` Run, cmd /K cd /D “C:\ ”2 R4 l* n& Z, x' E6 v5 i7 _
}) X$ N. S% g. k: W) }/ s( A; a7 U
}
6 A2 t" c3 z3 b8 J 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
6 @! u" G7 c: e ]0 j* U% Z 这段小代码肯能有两个你需要修改的地方
0 m0 @: y$ K0 g3 w0 H% e0 a 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
0 E) H9 q( s' C" E1 F- ^ 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
3 e/ b$ f; k: L% S; K |