此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。. n8 }' ^) K* [) v) L
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。& \9 t' P# @) Y; O) w# [- i: ^; g! p
方式一:+ u0 m4 ]8 ^' I5 H5 P
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,6 e! Y f: s1 F) u }8 ~
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
/ ^! e6 Q: S1 X V HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
, Q" Y, X% k) l$ O# N5 ~: } 方式二:9 X0 V. w T6 T$ }
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:( }% j( s9 {5 p: Y" c. ? s2 M
SetTitleMatchMode RegEx, z7 m4 ~* ^1 a7 s
return; ~' p* A8 W9 i+ c& F
; Stuff to do when Windows Explorer is open! U7 e: ~* s4 f9 m
;
, t% c) A. c6 n: q3 F% i4 F #IfWinActive ahk_class ExploreWClass|CabinetWClass- M" {" ^2 E* ~# M+ i! m
; open ‘cmd’ in the current directory0 [. K: i2 S/ F
;. K8 o* y, z! \4 F6 d. g6 x+ e
#c::
: ]$ C0 i' W% B j7 j% Z OpenCmdInCurrent()( Z! t( n1 s) J2 n2 n( r
return, W$ p' h0 ?5 u! d1 G
#IfWinActive
a% i& j+ [1 P, Z' @. x$ Z. `9 S; V ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
: \1 c; Q# r% B9 h7 I* ^; h7 r" S ; Note: expecting to be run when the active window is Explorer.
% d4 n9 J6 [% k8 q ;
$ t6 u7 X, O7 |, @) T; N OpenCmdInCurrent()
5 {" D8 O5 P+ `) [" _ {
! y# V$ m9 R" P) H ; This is required to get the full path of the file from the address bar
. H4 f( }8 X' [8 z" g WinGetText, full_path, A
+ R7 J: R" v: R" \' X' |6 B ; Split on newline (`n)9 G4 H4 j/ c- r3 c# R
StringSplit, word_array, full_path, `n
9 a% E: ?+ ^, S, X# P9 n+ ~8 ~4 _ ; Take the first element from the array* M: u( H$ J0 L! b4 I6 {& \2 U+ c
full_path = %word_array1%0 C/ m& ^5 j9 l
; strip to bare address( ? k ^ s+ p0 P
full_path := RegExReplace(full_path, “地址: “, “”)
( K/ b: V; f4 r ; Just in case – remove all carriage returns (`r)8 V0 k0 O" t# [* r+ z: ~
StringReplace, full_path, full_path, `r, , all
- s) @ F+ E0 ]! h IfInString full_path, \: x& u3 {$ v/ v$ S1 `: K9 {* O
{4 o+ e* W( N' X9 o
Run, cmd /K cd /D “%full_path%”
9 F* G6 M4 t7 j. q( E. ^8 P+ f }+ m' p7 _, X k! I% N
else' _, |" C) n: z$ w6 u5 O1 E6 u
{
7 e6 J* y) f7 |9 Z Run, cmd /K cd /D “C:\ ”1 J N* c& p) g! T3 w% R
}% w6 l) M" u1 v
}0 i5 w+ a& u1 [9 c
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。( k# \! ?) k6 y- f2 ?% [
这段小代码肯能有两个你需要修改的地方
# o) r' y" r3 B2 P0 c8 ^6 c 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
' s0 ]$ K3 l/ L/ S# D( R 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
4 H. u. u/ l% \% R' |( G, k2 b5 P2 Z- t |