此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。7 C8 u" F+ j+ l' O& S6 p
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
X3 {! _- }: k# }* s- f1 q2 {& c 方式一:! u6 L2 S5 t4 z) d: \
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
, U8 N8 p! _- A A4 r 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
: J, S X& _+ D* k HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。4 D) W7 R3 Q$ i# S; L: F. t1 a
方式二:
& X- u3 t4 g1 h& q1 s 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:3 h$ ]( f g% [# W9 F( X
SetTitleMatchMode RegEx" G( }' C/ I& g6 e
return+ y5 K2 D$ d6 ]( {; R
; Stuff to do when Windows Explorer is open0 C* I; E7 ?5 U! m! h8 Q; M/ t
;6 V; |, ~0 E T" O! Q) V
#IfWinActive ahk_class ExploreWClass|CabinetWClass6 C4 z m5 B3 Q4 h3 x2 Y8 M
; open ‘cmd’ in the current directory
e; N/ M$ |& N- w. }& A' p ;
9 I2 z8 B9 A( m+ r; I: d3 I: @ #c::4 ?8 ^1 D: P4 q
OpenCmdInCurrent()
: f* b- t/ d% q4 g# C: r return
! p& B: l8 ?' W. f #IfWinActive
3 D! |/ c( X+ D! m/ d" ?* u% \2 ]( u ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
9 _: i4 i; n5 s6 V& V, I0 e ; Note: expecting to be run when the active window is Explorer.; ?5 A* V2 B0 U$ C/ L5 r' @, O% F
;% c2 I/ W3 H- o. z p, K8 T
OpenCmdInCurrent()0 Q+ S L5 v. V; I) t6 S: m
{
; p# Y/ J# h& V0 R7 f# \' G, s ; This is required to get the full path of the file from the address bar- a' x1 b7 p$ U L) x3 j6 Y
WinGetText, full_path, A: V. q- o% n+ x/ u c" v
; Split on newline (`n)0 {. N2 ?+ w& c2 \) s
StringSplit, word_array, full_path, `n# t8 ~9 e% {! W% k4 U } N
; Take the first element from the array) v. |- \' r; H+ ^ ?' H9 Q
full_path = %word_array1%
$ S* v: W$ x V8 y; J6 ?+ I ; strip to bare address; B7 u( J( g, l7 L5 o. l$ Z3 |/ L
full_path := RegExReplace(full_path, “地址: “, “”)6 r- ~+ A _- r# t4 M; Y
; Just in case – remove all carriage returns (`r)
/ ]; j* _. x% w# b' e4 ] StringReplace, full_path, full_path, `r, , all' N) [2 X7 H/ m
IfInString full_path, \* S) X* U4 b6 c# {. `
{: F, Z1 M$ R: K
Run, cmd /K cd /D “%full_path%”2 F+ B: k# I9 d/ E$ M# ?
} Z4 L5 W/ @4 j
else
% X, N/ \3 [! L7 g3 G9 g {
/ a/ K0 l' ?* B8 ?# h% N Q Run, cmd /K cd /D “C:\ ”
, ~+ H4 {7 C: D3 g }, e! t7 I. L* \0 U% H4 b
}
' N4 C. ]7 G6 z2 W* k" `& c 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
7 e; G. B: B% G$ I& ~% A( v$ ~ 这段小代码肯能有两个你需要修改的地方2 W$ n( v. B, p& o, s* l+ P$ Y
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键" s) c& i# u0 E! n
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “9 H6 R/ K5 |, Q+ F/ v/ v
|