此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。1 i" {( h2 ]* U6 U
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
6 z# W8 B. C! b# C: x 方式一:
! P% u! C$ H( u# s- i; ? 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,. a- X# g: ^7 j$ [5 j# d% Z: F
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
3 l" x" ]" a$ O$ c HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。4 Y. O3 L6 k% h3 ^: a
方式二:6 R) A+ Q( D7 `- l7 N) x
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:! L, F+ z: H9 y
SetTitleMatchMode RegEx
% [$ D8 i1 q; m, Q2 k/ t return
! l5 u+ m/ U {9 W/ [/ r ; Stuff to do when Windows Explorer is open$ ^1 R* d% v# [: }( {& a. k
;$ X6 J( w1 n8 f9 B( N5 J
#IfWinActive ahk_class ExploreWClass|CabinetWClass
& m+ d8 k2 ]) H, \! ~1 A ; open ‘cmd’ in the current directory' }2 w+ G8 F$ _+ s$ G: y
;; c* m* Z0 B, t( @" W! ]3 P% Q
#c::
" @8 _) ~* H" j' V7 I$ i* ^( f OpenCmdInCurrent()* M! J( P% J/ t# B
return# f: w8 e: T9 g3 E) q, f7 V
#IfWinActive" l% x* \( [; x# m& h; x
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.: w. t5 E3 X% F4 d# N8 [/ K
; Note: expecting to be run when the active window is Explorer.% d. G7 W( B7 q
;
2 V7 a' l! g' k OpenCmdInCurrent()" o' s# E( b8 G) x, J7 d
{
# ` D* y0 C8 I) E& n& d ; This is required to get the full path of the file from the address bar
8 a3 g6 l* b8 W WinGetText, full_path, A% ]0 ~' L) e/ \' b, a! |
; Split on newline (`n)% G4 n( s& r; j: U9 K/ u
StringSplit, word_array, full_path, `n( x' s& [- s7 J6 h5 z4 H1 O Z6 \
; Take the first element from the array
) H: S' K! m! @# K: M2 \ full_path = %word_array1%- t$ G* ?0 k5 k% P9 B
; strip to bare address
/ k8 O* k$ t4 s4 O/ q1 @! A k/ v full_path := RegExReplace(full_path, “地址: “, “”)
/ A! K" _; y* ]1 Z% {9 ~- Q- A3 U ; Just in case – remove all carriage returns (`r)) c* X6 H9 X) ^" W; o2 w
StringReplace, full_path, full_path, `r, , all; R1 M/ E! r; N6 u" V* U5 X" h
IfInString full_path, \
0 K' ?5 ~6 c" G n4 ]: y! r {& Z" g( a+ O; N* S5 ~
Run, cmd /K cd /D “%full_path%”
3 g2 w+ a- ?% o! z' `$ X }! Y* _* b+ w3 }$ m- z
else i/ U" t+ i* |# J% r
{, n" U+ _ ?: d" i6 v
Run, cmd /K cd /D “C:\ ”7 I" }) N0 s- g r" H6 E- w
}
% z, b5 b7 t; T1 D' s( ~& I }/ O/ Q% ^+ L7 e3 U
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
: T9 M! m6 |: D9 e0 c& q1 } 这段小代码肯能有两个你需要修改的地方- X; j2 o) Q8 j+ C# c- G$ P, _2 P
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键3 o/ Y2 e; @4 X! }
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
2 F) m: k- r. V, m |