此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
3 ], X* {& p" n# @! I3 ?; E 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。! @% x$ e* h3 k, _4 \8 i. k- }# T
方式一:' \; S. F9 r2 G
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
' i4 \! [4 M5 W# P. I 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和+ ~3 h. }( g: _
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。4 D% ?5 ~" A( j% Z
方式二:. `4 i/ Y9 l2 I6 g5 I$ d; k
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:; w" |7 s* L( q k# L" M5 R
SetTitleMatchMode RegEx- T: R% Z/ M7 y3 w! o* ^0 ~
return
9 a# m' O& p) q2 Y: I5 ` ; Stuff to do when Windows Explorer is open
2 d- Z) v, R2 f% k9 k ;
6 p7 I8 i) M! p #IfWinActive ahk_class ExploreWClass|CabinetWClass
' d% D* E7 c5 N0 ?) B, f ; open ‘cmd’ in the current directory
Z5 ~, {' H- k1 r0 a( v& ? ;
" @: B3 S: ?$ q G, T0 T #c::* Z. Q. [) E" J$ ~ F
OpenCmdInCurrent()
% R9 d* P# t" m return& O0 o# _4 [# a4 n9 ~
#IfWinActive
. B# U+ W. I1 A ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
, g3 [5 A5 H) `2 t5 i ; Note: expecting to be run when the active window is Explorer.
& S& G5 G* u% r; N ;
2 L( H; r- L* ?' t: N OpenCmdInCurrent()( |! U: Q2 |( P( Q/ a$ N1 K* T
{ U( }5 ?3 B9 B2 {- ~3 p
; This is required to get the full path of the file from the address bar
! u. A5 W' Z% _" M R5 D9 |( b WinGetText, full_path, A
2 s; w& X/ u! T5 ? ; Split on newline (`n)
u2 S: m2 b9 V! k- y+ \: |" q StringSplit, word_array, full_path, `n+ x- r5 M; f! E/ e+ X8 ]% g9 _
; Take the first element from the array
3 t, Q: g: `; I: s full_path = %word_array1%
' t% n9 y7 G& @0 l/ j1 ~ ; strip to bare address0 ?/ G: p; p; d
full_path := RegExReplace(full_path, “地址: “, “”)
* P4 }& J: h9 S# O0 w$ V ; Just in case – remove all carriage returns (`r)- Y* S+ s3 V/ j. ~5 M/ c4 W
StringReplace, full_path, full_path, `r, , all$ ~; j) U; M& N! Y. I8 F
IfInString full_path, \
4 e/ d2 D4 e: \3 K( ~5 o w {
4 `: l) h$ M9 s Run, cmd /K cd /D “%full_path%”; Y) e, N& a! W3 i: Q
}
5 g2 q. f* t+ y# E" k3 ] else
/ ^" k# z6 o9 E. \5 L {, y" M0 a3 f x
Run, cmd /K cd /D “C:\ ”* ~" y* ]7 {' v% n. V
}
! @. M* [( h% g5 t) I }
% n0 X9 ~4 |5 L 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
! M& u, M$ R! g1 Z4 Z2 |& ?- t 这段小代码肯能有两个你需要修改的地方
# O1 W3 ~0 V: P2 {6 ~ 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
' `" i4 o4 w% U7 V; o% t% h 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “( n% ?0 p) l* [( R. F/ _
|