此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
' a4 k9 g) y* P3 a+ d* V' X! k 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。8 B# ]4 j: k! _+ J' f$ P
方式一:$ }, F$ p0 j) s' [
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
9 Z8 J- V4 i) ]) L9 l3 H }! C 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
8 ?- g! N& {9 X7 G; z+ v HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。; S! ^$ `6 a( Z& K7 g; I6 {0 I" b: A
方式二:/ f# l. m3 Y# N! G2 l3 ]7 |) G
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
( d* `6 T6 h. G- k5 t* b& | SetTitleMatchMode RegEx4 B* v( D- K+ P3 U1 E- V* P$ x m
return7 p& s/ [) z/ B3 S; p
; Stuff to do when Windows Explorer is open
( n1 Z6 N0 o% l; R ;
+ T% N1 Z) B6 L# m- ]' \/ w2 w: U #IfWinActive ahk_class ExploreWClass|CabinetWClass5 u0 p5 B( e8 U, `7 V' O) C6 ^
; open ‘cmd’ in the current directory
h7 f6 S$ t1 ~& N* f0 S ;
6 S( Y2 M2 V! B #c::
% x" U5 Y4 @, B: L+ E OpenCmdInCurrent()9 v, Z' Y) |( J+ J
return" \' q& R. L8 x( a
#IfWinActive% q: w* _' E* h8 h# l; S
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
7 y. l& x2 _/ |# Y% n$ m ; Note: expecting to be run when the active window is Explorer.
2 b" [8 S% z& ^5 G3 Z ;. h% N: j6 [1 p/ ^$ s/ b0 o
OpenCmdInCurrent()
9 R1 b8 J K2 Q7 `, n {) q6 C& h ]( ?4 U% q
; This is required to get the full path of the file from the address bar7 d! a/ l- |1 K9 u4 Y
WinGetText, full_path, A
3 d/ K$ k* H* g+ @5 h. I ; Split on newline (`n)) K* D! L. R" _1 m3 {+ o
StringSplit, word_array, full_path, `n- u" L1 R2 ~$ U
; Take the first element from the array
+ T5 y3 f+ C( L# I1 C4 M2 w full_path = %word_array1%0 x5 p$ \ R4 |% q9 v
; strip to bare address
4 h8 E4 e6 n6 y: u full_path := RegExReplace(full_path, “地址: “, “”). p* l( h$ e3 @3 Y' J% I
; Just in case – remove all carriage returns (`r)
; j, u0 C/ D8 V: S StringReplace, full_path, full_path, `r, , all$ R, @: i+ A, L h& }! y
IfInString full_path, \) v% Z) B* u s7 k/ V+ x F
{ H6 n# W3 y4 o
Run, cmd /K cd /D “%full_path%”
2 w, U# A, u( C8 U }
7 ]9 S5 |0 h! F9 x. j" ] else. ^4 a6 O3 Z2 G; M6 u" L# Y6 k
{- u6 |9 `4 V0 y
Run, cmd /K cd /D “C:\ ”& R+ u2 f$ l- U2 Y0 E
}1 P" ^4 o/ @5 H
}3 m! p4 P6 u# f6 M' V h3 o
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。# b' p) R& L4 k( l
这段小代码肯能有两个你需要修改的地方
6 e6 _) z" B4 i, H. \, h- I' f 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键- a' C" ^5 P: v9 s0 N9 R7 t
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “1 {* }; T% {1 q. S8 ~
|