此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
) L5 j& j U+ e, s# f8 { 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
9 Y- O8 {% |8 w6 o2 r5 O 方式一:- e" v, N5 I' K9 u# V9 Z8 J
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,7 I$ l1 T. F8 i' L" P! v
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
2 U) U: p9 M* T9 ^2 \/ | HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
?& x/ |6 g7 Y- x r 方式二:
5 @4 N5 {' w/ @! G& Z- G 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
2 E- H7 P8 E* B1 Z SetTitleMatchMode RegEx
7 U' d" m/ E2 v return. Z* ?' q; i% D; U- @# r0 @
; Stuff to do when Windows Explorer is open
% m8 }8 b1 ]1 [* W ;, ^* _1 N9 _3 i2 \" y6 x
#IfWinActive ahk_class ExploreWClass|CabinetWClass2 Z0 I# V, {4 v( b! `4 y, f
; open ‘cmd’ in the current directory3 @: q( J3 ^% C# W, X
;
% j* O0 L) [8 f9 a #c::3 y8 j& k( [* f N6 ?9 Y( V9 {
OpenCmdInCurrent()
: }& ?; ]# w( T& s& F* e& t return
7 R, A1 ]3 q3 M0 _ #IfWinActive
! {% f) J" i3 d* a8 F ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
7 R3 F" _$ [. K9 N' ]6 X/ | ; Note: expecting to be run when the active window is Explorer.. c: R5 l9 f7 c; |. q7 P) \) v
;
2 Y4 X# l4 e5 w0 s, E1 x OpenCmdInCurrent()
' v! _2 K' O3 I1 a5 M9 L/ r {" c3 W1 h/ T" w% M
; This is required to get the full path of the file from the address bar2 ^ M: L2 i" D4 K* F
WinGetText, full_path, A. T4 ?" p9 E" j: ~, T3 O# u+ @
; Split on newline (`n)9 L/ X/ M9 z" a& P
StringSplit, word_array, full_path, `n) K. a+ | z7 L2 I0 D5 `/ M2 e
; Take the first element from the array3 R9 p3 b" U$ n& E1 Y
full_path = %word_array1%
3 V0 ^( [' }3 t/ f8 w ; strip to bare address" x v9 L+ ]+ _8 ?8 D1 G
full_path := RegExReplace(full_path, “地址: “, “”)/ X4 p" k- i( y; v. q( E6 f" j
; Just in case – remove all carriage returns (`r)0 D" T8 b, `$ g9 m$ [+ T. {0 \: k$ B
StringReplace, full_path, full_path, `r, , all* `# {& n8 t0 @' x5 A6 P G
IfInString full_path, \
' D3 |, w; {' F; B' l {
0 K0 y' G" }1 ] ^0 J5 F Run, cmd /K cd /D “%full_path%”0 b. d9 P4 I$ b
}4 z+ I n' n& ]
else
" t, O; S" G/ v+ D6 P+ I: L {% q: D9 A8 r$ V+ y' ?% G. M
Run, cmd /K cd /D “C:\ ”, Y& W4 Z. G- ?! |5 T) T& W
}
9 H7 n, u9 F0 P1 B }6 C1 Z& T+ {8 I0 Z0 N
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
! ]$ B# H0 q0 ]8 ~ 这段小代码肯能有两个你需要修改的地方4 J. p9 o$ `$ U- V& y* L
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
7 i# j, i; w' d' d+ W: f$ f 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “( P5 b' E# d: s4 ]) a
|