此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
3 m- W# U% }6 o2 t6 f- V 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。0 h( W3 b& I8 F; \: i6 d: ]
方式一: M, `$ U( c' g( M) ?* W! t; K) F6 ?
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,. T) h$ W- ?! M6 `- z# W/ X; V
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和2 }2 `2 q: ]. P" Q" d/ B6 O W. R
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
6 `6 ?7 e! T- ~( X, b$ W5 l 方式二:; y; ]$ s: ~* B! z' L% S5 d7 M) R
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
# m) _! A5 } i3 m SetTitleMatchMode RegEx
9 l$ \: Z* W4 h, f( [- c7 N return( g9 g# N. @# g9 Z" m5 ?% E1 j
; Stuff to do when Windows Explorer is open0 n. ~* C9 P# i k. R A
;8 b7 A% d8 {9 R z" S+ y, b8 \
#IfWinActive ahk_class ExploreWClass|CabinetWClass3 S5 i. H B8 s6 o. s, k
; open ‘cmd’ in the current directory/ ~9 ?" ^8 b4 r! j& A6 y6 j
;3 \' Y I/ m0 m2 U# e# a
#c::
6 \) d) c9 l. H9 M4 e# C+ e0 p% b2 T OpenCmdInCurrent()
3 \! |! B) X$ Q return1 z! u7 a* d. M
#IfWinActive
7 V; l5 O$ S+ @ ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
. j( G& D9 B2 [ ; Note: expecting to be run when the active window is Explorer.5 z; e2 v: O" z( _/ H
;. z+ W4 p, b* W. J' o5 ], x
OpenCmdInCurrent()( l. n) N7 G$ `* g
{ u" o: X1 y0 o
; This is required to get the full path of the file from the address bar9 Z; u" _& O. R9 k9 n
WinGetText, full_path, A
2 C( G! v# Z7 @, [+ l ; Split on newline (`n)8 Q& Q: Y# @2 c2 B% X: l) X
StringSplit, word_array, full_path, `n- ]* t: e; S3 _
; Take the first element from the array5 b! ]5 A9 F0 b' v2 o9 U
full_path = %word_array1%
6 z5 l: T1 ?6 t' U$ T ; strip to bare address
1 N; R! U( M4 `% h/ x" h full_path := RegExReplace(full_path, “地址: “, “”)4 {! w6 l" s# n+ z, \
; Just in case – remove all carriage returns (`r)
# t% _0 r i# p3 ~; L& _ StringReplace, full_path, full_path, `r, , all9 }9 Q/ m5 P( w, @/ P6 y/ \
IfInString full_path, \
3 B: Q1 C, G/ Z; J3 S7 d; L0 S {
# H" {* M# h3 A" w8 o& ^8 Y7 v Run, cmd /K cd /D “%full_path%”
5 F' h4 w/ f7 ^ s9 Q: z }
$ N4 O! t% P- K& G else4 @9 E; x* v+ _0 M0 {
{
2 Z7 C/ b ?* N4 q$ r Run, cmd /K cd /D “C:\ ”1 r0 g. d7 x1 d( Y8 B; G) _- B
}/ m) l# j& O5 y' A, e- W
} Y [. u% s+ O' @1 F
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。7 O5 Z* ~9 w. ]! n; L0 t
这段小代码肯能有两个你需要修改的地方, \' d" q% r( U3 ^
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
. v0 m6 v5 D# K' M 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “, B& v, l5 |' i+ I
|