此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
( A! t; Z# t* f8 Z, Z 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
# z/ [6 c1 ~% T) P/ n$ g% T7 C 方式一:
0 h: t' C% ^) a, x8 c: e1 P 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,0 l2 T4 P p8 A( U& T2 N& t
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和. S2 O! j- R* q" U, \6 t" `+ y% s
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
4 I; H0 t; J. }1 U' H2 s 方式二:
( L; Z& X' K/ s( v3 H. I4 \ 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
1 o3 y1 ]8 o5 w; F! B SetTitleMatchMode RegEx8 }. w5 _3 x6 A, l( c Y- {' O/ C9 f
return
! N0 N7 c5 Q9 F/ [* J- l ; Stuff to do when Windows Explorer is open( k" M% ~6 M' ^* S4 I8 {% V$ r p
;
3 c# S3 B v9 i* S #IfWinActive ahk_class ExploreWClass|CabinetWClass
9 O3 i L( m K7 L" X ; open ‘cmd’ in the current directory4 G1 [; U3 D- }+ [, U% y# N
;
* X F$ G0 v ]- R #c::
6 ?5 N# y( t0 h3 `! k5 A/ c' P OpenCmdInCurrent()# b `# F& p. K
return! O4 K2 n" i) ^1 ^ e7 I6 ?
#IfWinActive
5 |) N( L' s4 O, { ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
$ Y' G. p. W" E: k' g ; Note: expecting to be run when the active window is Explorer.
3 t/ K& c% F: H6 p! ` I) V" n, N ;3 o0 @8 g9 A' f) N9 U
OpenCmdInCurrent()* G8 U: j1 b% W4 ?3 n
{
4 ]% a& Z$ f4 a8 T/ `/ u ; This is required to get the full path of the file from the address bar
5 x3 g3 J' M5 a WinGetText, full_path, A
! J" D5 }% v9 q& E n4 Q- v" Y ; Split on newline (`n)
) J: g2 o1 V. _1 w, x StringSplit, word_array, full_path, `n) h$ q# f: P- u$ b6 V5 U
; Take the first element from the array& [+ g' N9 x8 S) n5 ]0 g- A
full_path = %word_array1%' ^; u% Z5 i+ D |; r
; strip to bare address
t. V/ t. ^) d3 k4 I W' g, L full_path := RegExReplace(full_path, “地址: “, “”)
: ]6 t7 P9 x! d/ Y2 W8 o ; Just in case – remove all carriage returns (`r)
7 B" k! ?2 x/ H8 Y. q StringReplace, full_path, full_path, `r, , all# `8 O( U8 o4 N( l3 J
IfInString full_path, \
2 P% U5 D" e7 ~3 f. s {
6 T3 S. p9 I1 d3 ^ Run, cmd /K cd /D “%full_path%”
" b6 D; o3 Q4 L ~& L }
y$ d- Y5 k: ? else% i; Z: @( M* j8 D% g
{$ \) h, v+ f. T9 B& w
Run, cmd /K cd /D “C:\ ”( u6 U; e: ^7 O) k8 A/ o
}* z1 e' q! m( V& }
}5 R' A5 w# U/ I8 G3 t6 g0 w
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
8 P5 T" d( W& T( y; d 这段小代码肯能有两个你需要修改的地方' D# k: ~9 j3 H$ W# _
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
7 B+ u0 ?+ s9 C5 Y& {# C2 r: Z 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
& d3 d W) L; r |