此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
2 c8 P& A/ {& s7 @+ s7 i 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。! Z. T, J7 P8 k, Y3 {
方式一:
" z$ u6 p5 d z 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,0 J/ l4 Z/ U. [. g* g
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和1 Q3 K: o, y3 R7 k6 B" k8 ]4 P
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。0 t- W$ T7 E5 W" W
方式二:, Y8 v* B4 j% K0 J4 P5 s6 t
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
t# M; w. b p, Z8 h4 d SetTitleMatchMode RegEx% v; z. I" @: y! I
return
6 M* Z" f) L' I1 q4 k* a- i1 E ; Stuff to do when Windows Explorer is open
% w) a, q f; h" z$ x ;2 H2 U2 Y6 S2 v |4 x
#IfWinActive ahk_class ExploreWClass|CabinetWClass1 x+ }' E" n- M! F& u; u! q. V
; open ‘cmd’ in the current directory7 C. E: w# J2 T; L0 \
;, _$ I8 i% e8 W4 H
#c::" g8 O, X' y2 T* M" i2 X
OpenCmdInCurrent(). e% M( d" I- E% f
return; N3 Y: s3 O3 X/ ?
#IfWinActive$ y1 h$ q- Z6 A7 @2 b/ {1 q- O
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
2 V0 \0 k/ J& g ; Note: expecting to be run when the active window is Explorer.( Q8 {2 {/ X+ e
;0 H$ n1 l, e1 G, v
OpenCmdInCurrent()
. y7 X/ V3 W3 I( A9 v {8 y5 E9 Y; P8 G- `. }* S1 N7 Q
; This is required to get the full path of the file from the address bar3 X+ d# h3 K+ y5 Y+ ?
WinGetText, full_path, A$ t M5 n9 n" b6 E# \
; Split on newline (`n)
% a/ ]! \; n& c) ~ StringSplit, word_array, full_path, `n. G0 e+ |( p/ t+ |5 M* `! w# p3 c
; Take the first element from the array$ ?& u+ t; ]6 R4 R) H' ?8 Q
full_path = %word_array1%# d/ Y: J7 [" e/ q
; strip to bare address; x, M- Q! z J; L7 R
full_path := RegExReplace(full_path, “地址: “, “”)
7 `; c4 ~" ~" o; C ; Just in case – remove all carriage returns (`r)' p5 ]1 }) P6 o. d, l
StringReplace, full_path, full_path, `r, , all6 k. I* f6 b! I! f
IfInString full_path, \8 T- D& a2 j$ C, U. t6 U8 j5 r
{7 G5 f( m8 d! C' w$ X' L( m5 @
Run, cmd /K cd /D “%full_path%”
* N0 x9 M+ {) P7 g5 I9 z% R }$ q, d/ S5 v1 ]+ T) Y+ ]: w" d
else
+ }2 r2 ~# `* W {: g2 a6 }% B0 v! R& ?8 w$ l& t* ?! J
Run, cmd /K cd /D “C:\ ”
2 f0 }4 E; Q, C }6 k0 q" ^9 W0 W. j. b% t$ V6 x
}
0 I( @8 l1 A1 R: Y 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
) a& p; A* d/ T3 b. y6 ?- t+ @1 o 这段小代码肯能有两个你需要修改的地方* R, e, v# x% N
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
0 v$ V+ Z3 Y0 ] X 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
1 e# T7 z: r y9 j0 }: w |