此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。2 X2 V" O1 G# q6 I2 i( d$ c- E
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。, E& u+ \1 Y7 Z! x! z; G4 a4 h
方式一:
4 Q* t3 Y3 C* m1 J 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表, Q) ?* Z8 F" O: s: W
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
" q" |7 a) [0 Q/ f2 u HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。, g. L/ d# n/ P! h- b7 R3 K
方式二:! \* |% d {: t7 `. Z6 v
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:& a3 j) p9 ^* c3 M+ B& K
SetTitleMatchMode RegEx' ]" ]# i" D) H. C- {
return: d8 ]: a' O# p; P/ ~" E, X
; Stuff to do when Windows Explorer is open7 e# f; J( B# T$ h* n
;# u! q# \/ L; B3 I$ v% F4 U
#IfWinActive ahk_class ExploreWClass|CabinetWClass
4 A) A; G7 R7 o) J ; open ‘cmd’ in the current directory
5 H% z; ]+ d# H, m2 x, ~1 L9 ? ;( I- G4 H4 F7 s' c4 {3 N9 B' N
#c::
" ]2 J/ b; y; [8 X0 U OpenCmdInCurrent()5 A' n% I9 i ~9 O' J2 q( j' B
return; y0 z: n( [. N" L8 x( w* |
#IfWinActive3 K ~. W! L; p3 |/ M3 z9 z
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.$ V& K3 T# X( u* ~
; Note: expecting to be run when the active window is Explorer.
$ I' c8 y0 _$ U: v- }' J& Y ;
; w; I# j) }5 L) V5 D" D+ z6 Y OpenCmdInCurrent()
c! @. t% U- a$ v3 S {7 E0 W/ B3 P7 P
; This is required to get the full path of the file from the address bar8 _5 ]9 f& W2 S0 \. a$ a3 J
WinGetText, full_path, A- P, n- d. c' H) V
; Split on newline (`n)" K' {" y' B: J* K. g
StringSplit, word_array, full_path, `n6 b9 u0 ]! B' S8 y7 z
; Take the first element from the array
e+ K8 `% W2 u' `1 A full_path = %word_array1%- B1 b) _0 |/ j8 h$ {; {
; strip to bare address" [6 B# `( N# w* q6 }
full_path := RegExReplace(full_path, “地址: “, “”)
6 C8 A1 {7 j4 N5 I ; Just in case – remove all carriage returns (`r)/ y- b! c, @& U, {1 u2 z* D
StringReplace, full_path, full_path, `r, , all
& h. b0 _0 N# t% D. n IfInString full_path, \
9 @/ f" D" j; T. l8 s* h/ s {
5 q. c/ Z3 m* ]6 r9 A7 @ Run, cmd /K cd /D “%full_path%”% s" q1 C( U4 k) k
}* ^: N5 r" g& u& I) T- M
else" |1 w/ c0 O' C* a* d6 q+ ]9 h
{
8 V4 r; p% l" w* c0 O8 s# D3 N Run, cmd /K cd /D “C:\ ”# z( }8 P4 B. _% F
}
) M+ E7 q# g$ E% Y }5 y# Q1 I* G! h ?4 j" ~
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
6 e4 S% `" p9 U0 y4 d/ _6 ` 这段小代码肯能有两个你需要修改的地方' b9 z8 X4 c1 t8 Z% y
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
) F( Z( ^. |3 \7 p 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “* |8 C- B+ V; D3 _5 B0 n6 G( k
|