此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
# c* C- q( F/ D% Q* {5 k 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
; _7 L; ]4 G+ _- I3 i 方式一:8 u# c& j" { b! j
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
1 `, G6 W) l" H W h% T& ~% b. N 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
( T9 N+ G2 ?0 \1 ~ HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
8 l7 B# g1 k4 @: n1 D6 z8 f 方式二:
8 m" E% @8 B! | 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:9 v8 m* L L$ u" F
SetTitleMatchMode RegEx
' C8 b9 _: h' s- W | return/ X2 d7 b2 p% l L4 M# X
; Stuff to do when Windows Explorer is open# Z. D4 [* x# e8 b8 D ?) ?* u1 h
;
/ n4 C: ~$ F5 p8 \: _ U #IfWinActive ahk_class ExploreWClass|CabinetWClass
j( n. U$ h- x7 D9 \& X! _( O ; open ‘cmd’ in the current directory8 e0 T' r5 o$ ]* Y7 M0 p t
;
" e& Y1 g; ^1 K' j/ C4 } #c::& S b# A/ P2 }1 F& W& G. ^. q& ~ U; B$ F
OpenCmdInCurrent()
: S; @. K+ r$ s# F9 @. f return
. e0 U5 E8 W6 P #IfWinActive7 w3 r0 t6 f7 h- K+ B0 [" z8 T
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.; [( d" i2 q1 l+ |3 l
; Note: expecting to be run when the active window is Explorer.
" `9 T& j, v; _ ;3 x/ W$ h) S' W" n
OpenCmdInCurrent()
3 b- C; D: e9 O. {/ T6 @ {' v0 u2 l% J; S' g
; This is required to get the full path of the file from the address bar/ n6 E N1 {8 \) r* M' L
WinGetText, full_path, A
/ a& `7 [0 ^. e, c% w1 F ; Split on newline (`n): A- |$ Q! ~3 F& H7 }6 v
StringSplit, word_array, full_path, `n
* t/ l& O" r- D( l ; Take the first element from the array7 K& O0 }- l) `" W9 L [" K
full_path = %word_array1%; d) v8 w% a( t
; strip to bare address
3 c3 I% y* Z6 F# { full_path := RegExReplace(full_path, “地址: “, “”)# V" I) W H! x3 Q; E
; Just in case – remove all carriage returns (`r)
! e! N: R1 K8 T StringReplace, full_path, full_path, `r, , all
5 n0 N! d3 B* D IfInString full_path, \
8 f/ s$ l! o& {! N( p {
) G" |1 H( o+ g$ n1 X+ J6 | Run, cmd /K cd /D “%full_path%”" E, w. `- A, B y$ n# H \
}/ g6 l; p- L T7 r- c7 }- \
else' `2 U) f' X' v5 _* }: v5 X
{2 O: P$ k) `$ {2 z, s
Run, cmd /K cd /D “C:\ ”
& J+ I# c/ c6 q! w6 K: @ }4 R* i' S0 O" c3 {: J( o
}) B. G2 l/ ^& z, w; O$ M. Y$ K# P
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
7 |1 i* V8 K2 `% J 这段小代码肯能有两个你需要修改的地方+ H0 ]0 l5 y! N
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键) | G/ j0 l- }* {8 b8 h. G$ ^6 z
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “+ q: u# c! B8 [; f3 V
|