此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。( E I8 O$ m& \& Z6 z
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。- P) P1 ]; J8 v8 [6 ?. N
方式一:
' H* Q8 A# n* H- @0 [4 I 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,7 y( l4 c' Y8 Y; p) ~2 R$ f) i
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和 }0 v6 b2 j4 S) r, g
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。' F5 {) I4 f0 J+ b9 H$ c
方式二:
e9 T$ F# x7 Y5 c( u 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:) h0 ?% D, H m! t8 b
SetTitleMatchMode RegEx
2 x# F- D6 H. Z( V return* }2 ^3 ~* e2 r- i( {! ~0 o
; Stuff to do when Windows Explorer is open
5 V7 C9 R. b+ W7 ^ ;
# R# D. ~$ y' P; y5 ^/ } #IfWinActive ahk_class ExploreWClass|CabinetWClass- N! R; p' F: H5 e! R$ s" D8 x. v
; open ‘cmd’ in the current directory
3 r& i9 y; z9 k' Q! U1 @ ;
2 r6 S/ X; t* n7 F! ~8 X! q #c::% W- m* x, A( L0 \7 ?
OpenCmdInCurrent() F$ P9 J! S# _9 q! [4 u
return
/ u3 A* `* ~6 Q, T7 ?8 a #IfWinActive& U+ O2 h ~7 v# Z
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.+ g1 ?% R; i% u! n# x" G& J2 u
; Note: expecting to be run when the active window is Explorer.$ y: f1 c- l: W6 [: Q4 B% f
; S; [/ Y) H4 @6 l. H
OpenCmdInCurrent()
2 r/ z- \ U) ~# ?: A% a {' A7 M. c! V) Q
; This is required to get the full path of the file from the address bar' q& q% G2 j c0 z8 M
WinGetText, full_path, A6 }8 N0 B" o/ s+ ^/ h
; Split on newline (`n). `/ |, L# C6 t: s! V Y' j }6 M
StringSplit, word_array, full_path, `n% Y- s- Y8 |) \. e: [$ Z
; Take the first element from the array
: d9 e, t" d8 k full_path = %word_array1%) P# F+ R6 Q9 w5 C! S
; strip to bare address! T( F5 U% }0 C+ `5 W& h
full_path := RegExReplace(full_path, “地址: “, “”)
4 R; C& S% C- N ; Just in case – remove all carriage returns (`r)% ^ o2 x/ l, d) @: f7 N
StringReplace, full_path, full_path, `r, , all( A U9 T% R5 I8 }" d
IfInString full_path, \. x$ Z* j9 E' W: A% c% I
{; \. C3 Z3 @" A
Run, cmd /K cd /D “%full_path%”
7 V8 W) S: k/ U3 q, l1 n0 o }8 x/ B5 Q; T5 F1 Q$ D; {. m' W
else
8 P: \2 m& P2 p1 P3 O4 _. `1 r {
# j; s0 ~/ B% h" L$ R Run, cmd /K cd /D “C:\ ”
# V" q# _5 u, K: p) D }2 R! `! u& X- a
}- Z" I1 l& x+ y( V: Y
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。2 `1 Y% k8 k( U2 v2 I" X4 w% j
这段小代码肯能有两个你需要修改的地方5 u3 i! c9 J3 t& f6 f2 w: A# j$ c
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键5 B: T9 k( T. t6 C- ^% D
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “2 [* a0 }* o1 u
|