此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。/ E8 u: ]# V- t1 {# k2 ^7 Z
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。" v4 i7 N9 [2 @+ \) I; v# V
方式一:
W# ?8 P: @- R- C8 E1 w) Z# G 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
/ r; W |" V8 ?$ K' I& m) i; T! d6 w 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和6 c2 T) I# P/ ?0 j1 N6 A* z
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
( I, j0 \5 c* k# i2 H( v. s* o 方式二:; h2 C; r% n" E+ X3 _
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
3 g2 W- p& ]0 t1 `9 u4 ~5 Q. q SetTitleMatchMode RegEx
( G* I/ i) G. z6 \8 W9 z return
4 e0 l& u" L# W5 [ ; Stuff to do when Windows Explorer is open
. G/ c' C+ k4 S; s: n ;, G3 i- |2 n P9 g; z' g6 q% ?
#IfWinActive ahk_class ExploreWClass|CabinetWClass
# G% ~" L# d1 Q' j f8 _' | ; open ‘cmd’ in the current directory0 @( i- |3 j# p! U* [$ m1 H: Y
;. f, D5 A! J0 X
#c::
6 l1 U9 k2 J! L OpenCmdInCurrent()' t/ L8 i; }, B$ \( l+ B
return* T9 h7 z+ _% Y
#IfWinActive( W; Y1 [, B' b+ f
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.' a1 ?) `: _% [0 D& e# p
; Note: expecting to be run when the active window is Explorer.
; ~( q) R+ t% ^1 G5 z ;, L* r' C( B( @
OpenCmdInCurrent()
9 ^/ N9 P1 a; a. Z$ m {& N" q) \* J) d
; This is required to get the full path of the file from the address bar6 d. z. H! l4 }
WinGetText, full_path, A; m- y6 {) b M7 W* C: ~& O
; Split on newline (`n)
$ c' k" G! _, V- q1 w5 s a StringSplit, word_array, full_path, `n- m3 S8 R8 E v& {2 c* I$ P
; Take the first element from the array! d" \9 O/ S; I% ^% d R8 y
full_path = %word_array1%( i. G. f! m7 b" q# K
; strip to bare address
1 b: X' I3 R; i4 q- X) Q- W full_path := RegExReplace(full_path, “地址: “, “”)
& Y8 x1 b o7 E( ^ ; Just in case – remove all carriage returns (`r)
9 X4 A% J0 t; J StringReplace, full_path, full_path, `r, , all
# g2 i( C0 h# Y$ c/ V+ ] [ IfInString full_path, \% d: ?0 p! l" _9 o8 c, l$ [' L
{
+ ^; j, Y0 u6 Q* ^ Run, cmd /K cd /D “%full_path%”
# d# \# V, z/ f5 L% b. m5 s }# D' M* |; L- D* P! H
else
7 S O% ?2 V5 i% l! E {5 b& n+ m# A+ V7 `, D, C
Run, cmd /K cd /D “C:\ ”2 O$ b! _+ N9 ~$ {) X1 \$ d! W. i7 Q
}
* J) W2 n4 l* M8 G6 g# J; u }1 i3 m7 H1 m* ]
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
& e) m2 F' P9 T6 ~! n' @4 f/ ]% ^ 这段小代码肯能有两个你需要修改的地方# |8 F' h1 f: A/ K4 @* f7 r/ S
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
: E' c4 `7 s' ?0 U3 \, ?! f8 G 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “ \3 ~& F0 S9 P% N* I
|