此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。3 n" c" X& o3 s/ k9 Q
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。' Y; G2 N7 b* Y6 l0 b/ s2 U3 x
方式一:
' h3 h0 ^, b7 N9 ?7 p2 v; [ U3 r 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
5 @3 c7 Z# a8 S$ T6 M 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和; o, M, \8 j. _2 F. Y. d
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。: B" h0 R5 I+ h+ b6 T
方式二:
1 T0 ?9 _; [- K d6 C 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
- b( B9 R. O. M- O# \9 N7 L/ t5 Q1 Q' t SetTitleMatchMode RegEx
2 _/ q! s5 _6 C return2 w7 F2 F: B4 Y0 y
; Stuff to do when Windows Explorer is open
' W3 \( h( M c ;8 T) E2 n" e. G/ f; G
#IfWinActive ahk_class ExploreWClass|CabinetWClass# E \# l/ A' K* C1 U( J
; open ‘cmd’ in the current directory0 c! n1 o7 K+ _! ^
;8 d2 A+ D( B/ R; f" ?" X p
#c::! D3 q, N% N. M0 |
OpenCmdInCurrent()
2 l \+ Q# l# ~& p0 P1 k" M" D A return5 f! Q3 y* S) c/ h: b ]; ]4 A8 S2 h
#IfWinActive
" P/ J3 k, y/ d6 S ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.7 _- d, U8 [1 W* H
; Note: expecting to be run when the active window is Explorer.1 K1 [6 O* B: w- P" C6 I6 l& v$ ~+ l
;
9 J1 L3 F! F! V* O8 d7 P OpenCmdInCurrent()
" g' E4 y% C. Q( u9 I {' h. q& {4 S- z/ F/ L6 k9 c/ r. C
; This is required to get the full path of the file from the address bar
0 }% X0 ~9 R# y2 N5 z/ a+ q7 m WinGetText, full_path, A5 b4 Y v: w: T. \% ^
; Split on newline (`n)* T# f' `. y' p, t! S. I3 n
StringSplit, word_array, full_path, `n
( u' n3 O# U7 h j3 B ; Take the first element from the array
L' o7 U9 x+ \4 J6 U full_path = %word_array1%
J/ Q! G* [! H. k ; strip to bare address1 s9 h4 x; }, P3 |
full_path := RegExReplace(full_path, “地址: “, “”)
1 b" G+ d* m2 q9 P, ~6 f- q1 e, z& t ; Just in case – remove all carriage returns (`r)
/ ]8 ?. w) o) x- W* N6 T StringReplace, full_path, full_path, `r, , all. y& ^) ^% Q7 x
IfInString full_path, \8 `5 m( O' d0 \* K
{ T. i* \7 F! }7 B9 d- Y! h' x
Run, cmd /K cd /D “%full_path%”
, S! Z" P1 P2 S+ E }. ?7 y- S+ C; p% w% ?% t, y6 ]. D
else/ Q$ C8 S5 l# a8 i
{* ^& E* t0 F; y4 U0 ^9 n
Run, cmd /K cd /D “C:\ ”9 h. k' Q7 |* l/ ^5 h% x
}% k4 Z1 @# n. T
}
, W1 a4 U) Z& K+ G 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
# _8 P2 V$ D. n; v& y: w' c% d 这段小代码肯能有两个你需要修改的地方
5 k3 E) r) i j# u 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
: u0 f, B0 H# u1 b9 q# m 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
! Z6 B8 }9 o$ u% b4 M |