此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
1 c# \& X( y0 X2 q$ D0 W. s4 g. f 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。& m9 a) M; a, {" k
方式一:
; c/ }3 Y6 z- M 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
1 z, W! l) V7 x5 M; R 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和5 d$ B; x0 G) m8 P) g9 u0 F$ f, H
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。! Z" P% n$ S! f3 S0 k- z1 c
方式二:% S: n; J6 H! o/ m0 ~
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
# j7 p! z% r% f2 u# o; \+ b SetTitleMatchMode RegEx! N6 Z! T8 k. s# j
return* I- ~" j7 V# G2 O/ t8 P' f' @# {
; Stuff to do when Windows Explorer is open
7 [* g7 b! ^. F% G4 T+ b3 q! I! `2 O ; L0 `7 e; ?( T
#IfWinActive ahk_class ExploreWClass|CabinetWClass6 l0 t3 x. w$ X' r/ _" ~ a. N- h
; open ‘cmd’ in the current directory
9 C! s; y* K5 [# l& X ;$ T! D% g! H# `. m5 k7 p& C7 i
#c:: |1 r7 b; A8 h9 X
OpenCmdInCurrent()
. _$ s, e0 N8 z, C- ]9 T( O1 U return. V' ]7 P8 j! e2 }" @
#IfWinActive
! l3 n& f; @3 o- z" ^; R/ X ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
{8 ~/ E2 z( E1 s) D ; Note: expecting to be run when the active window is Explorer.
. k4 w7 M. \4 F$ H8 n, o ;8 g$ g, p/ w/ y/ W
OpenCmdInCurrent()
; F; q3 u w( w3 S: B {
3 V W! L! U# x% S0 j6 j! F8 c& s ; This is required to get the full path of the file from the address bar
+ @* \/ _1 b* q5 S WinGetText, full_path, A
9 J7 F- P a; I7 y) ~% Y ; Split on newline (`n)
5 S' Q* f9 X8 m8 x0 O. g9 A. }! Q StringSplit, word_array, full_path, `n6 q' L8 \$ ^3 Y, a# O
; Take the first element from the array
/ a B8 q/ S& |6 g% }2 G full_path = %word_array1%6 C( ~" j9 z9 T& _' A8 e: J6 T
; strip to bare address; b d, r. ?7 P& o7 Y
full_path := RegExReplace(full_path, “地址: “, “”)% o& ?- u1 b% p0 h% H5 U2 g0 w8 F8 _
; Just in case – remove all carriage returns (`r)
7 s7 |1 u) U( f8 _. j- N/ H StringReplace, full_path, full_path, `r, , all0 d! W6 l2 z. E) Z/ }! n! p9 E4 R
IfInString full_path, \. N5 q3 | Z3 T" v5 d& _# j
{2 ?: _# @ r; O- r5 f7 ?0 Q
Run, cmd /K cd /D “%full_path%”0 i* r: D0 N! l1 i8 X: H7 b8 a
}
t6 T- o0 N% i& L5 M8 w else
0 h: Y+ W! G0 q1 |& i' W# I$ p, K- j {/ [! R/ L3 y9 ]! b
Run, cmd /K cd /D “C:\ ”% o4 t# }- F' k( e' J
}
$ y! k4 A; @. o7 b& {- n' l }
8 Z) X8 a7 i1 _" y# ^ 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
' y6 C: E6 R6 y& }; i2 M" J 这段小代码肯能有两个你需要修改的地方
& J/ e1 [6 G- a6 H, p$ p, W, \- a 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
( k4 i+ N5 g+ J1 ~; R 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
, i- C% C- n% E9 p |