此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
+ ], B2 V9 T3 `# |7 M$ x) t 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。/ |2 A# F2 m# z, l: P3 ?5 m5 D- |
方式一:* U T" h B6 ~
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
& I5 p0 E0 _1 l( l" M7 h' ]1 H% e 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和& a4 q* q" e) K6 M+ A2 \
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
( {7 @6 h. E# l; F* A 方式二:
* j" |. l' |6 n% E* F; j) q 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:5 I$ t9 @. S. I0 T3 Q
SetTitleMatchMode RegEx& O, ~. n2 p2 D% m B0 D
return8 Y' J: U* h! j+ u/ n! Y. i: A
; Stuff to do when Windows Explorer is open4 }! x+ I6 ^" r2 p ^+ E
;
; Z: y' r! X: s2 X #IfWinActive ahk_class ExploreWClass|CabinetWClass0 Y6 ^& \8 e4 r( C& ~9 p
; open ‘cmd’ in the current directory! x: D& ]! j) }/ {& n/ C- |/ T
;$ M9 d7 C3 w1 g0 `/ r8 J
#c::' ]7 Y# s' M, y, X" W9 E2 @+ i8 I. ~
OpenCmdInCurrent()8 d$ y# j2 y& |" K2 ^
return
- ]+ R& `( A' ~$ v# j5 E #IfWinActive
9 m/ w% s2 B4 o2 U0 g ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.. [, P/ u: T+ V
; Note: expecting to be run when the active window is Explorer.6 O- {/ _0 j$ u! r& w& W) |) E( M
;
. @& Q5 j# f3 B7 `9 y3 i OpenCmdInCurrent()
" l0 s6 n7 k7 Z9 p8 r6 q {; M! D+ E3 F1 b# }
; This is required to get the full path of the file from the address bar( z$ M7 \" i2 t8 b
WinGetText, full_path, A* W0 `9 j- N" ?$ u: Y
; Split on newline (`n)
2 o+ C0 l' J$ y8 F% ^ StringSplit, word_array, full_path, `n; S% u0 h0 |* B$ q( ]/ [& S8 l8 C/ s
; Take the first element from the array
( ~9 M1 m* M: e: N8 V) a8 w0 h) k full_path = %word_array1%8 h0 z. i, V0 J4 [
; strip to bare address& V8 D4 ?! W5 A/ W* a5 C
full_path := RegExReplace(full_path, “地址: “, “”)& t, x6 ?8 D! [) L
; Just in case – remove all carriage returns (`r)8 x+ t" T1 O! Q8 I
StringReplace, full_path, full_path, `r, , all
b$ K3 C' R8 e IfInString full_path, \
0 E. K0 c5 {/ Y0 k1 `5 _5 V% w {- w G- k/ ]3 |& M/ `, |# A* V' w
Run, cmd /K cd /D “%full_path%”
, U# D8 G% g( I& _9 Q3 L! r3 X }
" |6 L2 i. `) n5 {3 C7 v else
5 d! i7 |; m+ p5 | {
. A! w. `1 ^( {$ b& m' w: C Run, cmd /K cd /D “C:\ ”9 w+ T( y8 F, E* u [& u W& A
}6 c/ n, Z" t z( s! v
}
; f/ E! `) _* ?9 X* | r; ]5 W 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。 k+ }+ L5 `5 C) a% w7 {! Z) g/ f
这段小代码肯能有两个你需要修改的地方2 i6 e& i2 f6 T: `
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键0 [0 m1 T' e8 [; i
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “" Z/ V: C! F/ j# Q
|