此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
3 M3 }& S" z0 a7 d# Z% V1 M$ k# ? 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
( Z U; n( h: p9 G 方式一:5 T d9 a' h' @- T
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,3 ]' {$ ~9 `& ?# p8 W. i w1 }
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
. ^% R8 S% [- K0 p HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
E6 }( a; X% _" z 方式二:. a" E1 f# e& L! e- a$ T
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
7 p$ u; m! j& k3 R* c, G SetTitleMatchMode RegEx: F" F) j5 x; Y- w
return
1 ]: k" E, S' _& L$ Z3 Z% { ; Stuff to do when Windows Explorer is open
1 N* [8 U! B6 t ;
. y& R2 U# h6 C2 t! x6 K( K #IfWinActive ahk_class ExploreWClass|CabinetWClass
. _2 h% t! ^+ {1 t ; open ‘cmd’ in the current directory
! ?: W1 E- ?1 q# S6 D% @+ s ;+ W; c( E7 T Z3 d0 b# f: y
#c::1 B6 t1 b( U5 M2 p" R+ @! s% W
OpenCmdInCurrent()
. d/ d7 Y, m- Q/ J1 ?9 Z: N return
1 I0 I: Q) C5 Y* [% k2 L #IfWinActive$ \+ {5 q y5 S4 K4 F- o
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
) @! q+ _) c+ k9 C( t4 Z2 c ; Note: expecting to be run when the active window is Explorer.
# p4 G$ B' c2 s ;
1 D. ~3 k0 O0 s5 G5 f& h OpenCmdInCurrent()' c. Z) b+ _+ U' U! c8 B
{
3 |* J2 a( B) k- O, R ; This is required to get the full path of the file from the address bar
; n/ T5 |: n( S4 W$ _6 t WinGetText, full_path, A/ E1 G5 m& R$ Z# s
; Split on newline (`n)
8 i6 V2 H3 P! l1 F2 h, I StringSplit, word_array, full_path, `n0 m- k" C, P8 W+ I( K, M9 o1 ^; y4 ^
; Take the first element from the array7 ^: i; V n, J7 D8 ^
full_path = %word_array1%. @' l1 [6 s ^; h% G9 x, V
; strip to bare address
! W; z8 Z/ F+ _2 R full_path := RegExReplace(full_path, “地址: “, “”)
o& b" w7 y( J( U: k6 z ; Just in case – remove all carriage returns (`r)+ {/ P6 t' T6 X; _8 o" T
StringReplace, full_path, full_path, `r, , all
/ ]2 Q+ a! b3 K. {( r' ^ IfInString full_path, \
0 h* q! l' r) I1 k+ z {7 p, Y4 d* ^8 z; A9 m& S
Run, cmd /K cd /D “%full_path%”
) P4 c) ^" V% d! ]4 B; O, ~# M }' v3 y# x9 y; A* q8 h" @5 \
else/ @3 W5 \, r0 T# I& P: r
{2 t7 Y# ^5 G# H r& i
Run, cmd /K cd /D “C:\ ”
! t" U* o: Z6 \8 Z2 A }9 {9 s% _8 R# L! r8 w4 n: {! `+ J
}
& l7 a/ r1 i( g! a 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
K6 R* M, ~+ ?$ V. R. ]+ X 这段小代码肯能有两个你需要修改的地方3 L% j; y" y7 A. y% n3 }
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
) f8 x1 E. @& M. b _- N 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “* a6 b3 }0 e' o l/ { [0 }
|