此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。 ?! [+ _4 j( m0 }# k9 @
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
0 x! }, e( d5 ^, y# [/ H 方式一:2 X9 ~0 e# M$ R# I% d
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,5 @; G+ h- h( h9 T5 |
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和) K( @" x% X: C0 F. x
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
* e; Y: j0 P; ^ 方式二:
1 e( h2 y1 l1 P s" n1 M8 o: S 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
" P4 G7 c. x4 ]5 l! P" i8 E4 ? SetTitleMatchMode RegEx9 }* C: }5 D, U: Q
return9 S( g5 ^5 k! H8 L$ l2 g6 {
; Stuff to do when Windows Explorer is open
I% A9 ]% ` ?, t1 z ;
4 |6 S; \# t: f5 { #IfWinActive ahk_class ExploreWClass|CabinetWClass
: E1 B. I7 y# e5 G+ y/ H$ U& J4 m ; open ‘cmd’ in the current directory
: D+ ~; D+ V1 h* k7 a ;# i a2 ]# C U/ A
#c::" s2 Q) l' I, u m6 {# D* F. s+ Y
OpenCmdInCurrent()
$ A- j! u/ {8 c0 y6 J6 d5 V/ L return+ Z2 v* M' N8 D3 z. d# C
#IfWinActive$ A. E1 }& r& i. h
; Opens the command shell ‘cmd’ in the directory browsed in Explorer. P4 S e9 z l) j# E
; Note: expecting to be run when the active window is Explorer.
" [8 v- F1 K Q5 D) e ;" W7 h. y! [/ f
OpenCmdInCurrent()- z: W% ^2 y* d( A# _8 U
{7 G M8 M. L! X0 o
; This is required to get the full path of the file from the address bar0 S9 t/ ]& ^2 V9 X" V8 i# d( P
WinGetText, full_path, A9 w. z. c6 d8 i+ }3 ?
; Split on newline (`n)$ D' m+ Y, q: K! x
StringSplit, word_array, full_path, `n! h5 ? Z8 w$ n2 \+ v/ D2 Z
; Take the first element from the array
: c9 T o g0 m8 B" _6 O( }1 a$ w full_path = %word_array1%0 B+ E2 v/ ]( Y8 U5 P- C7 a
; strip to bare address
) E6 {6 L$ ^; q2 K) h full_path := RegExReplace(full_path, “地址: “, “”)8 o: Q" K" k/ U) k
; Just in case – remove all carriage returns (`r)
* ~ q3 f# }, H; s4 ? StringReplace, full_path, full_path, `r, , all" f2 x8 F* u) p' q5 M
IfInString full_path, \9 y8 b; o) z6 n7 ]* p7 }
{
8 a4 ^! j0 e4 G0 b% J# C) ` Run, cmd /K cd /D “%full_path%”
1 p: P/ L c: Q }# @. a$ v" ?4 ~ T b
else
1 t1 ]0 }9 P( M# v {/ L7 l& b, i+ |8 r
Run, cmd /K cd /D “C:\ ”# p# f5 O- ^! P* S& A, [; K
}
: R) |# ~+ q* ^! J$ q# z }
$ P9 _5 [2 y$ k) d2 m/ a 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
2 _9 b1 H& T7 q2 r+ x 这段小代码肯能有两个你需要修改的地方: R, E* k# G3 {/ }' a" ^
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
+ W! z2 S5 A c1 e7 q4 K' V# t ] 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
/ Y! k8 C% v# l! I1 G1 q |