此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。% W( B- t4 \: D4 F$ j
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。7 Y( u3 X, c l- n1 T! |& y% ~! a
方式一:
: H4 t9 W7 k! r! W: O% E; b 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,3 |5 ~, z0 d( V% U5 T
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
) u8 N/ W- k* o; C4 b9 M HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
& L: ~' g3 M. W0 h% @ 方式二:
/ N% u7 B. n: b) A' J' m2 c& M 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:! }, P2 `1 _" p0 B( p7 Q8 ?
SetTitleMatchMode RegEx
: L$ h3 z8 f3 K3 @9 s) y return# n v" a& r6 A# {
; Stuff to do when Windows Explorer is open
$ }+ G2 c* o/ ?( q# q. y* m2 V% g ;
8 t# [, Q. M1 f% i4 |) O. l z #IfWinActive ahk_class ExploreWClass|CabinetWClass
9 b. v' P$ L, G( Y# ] ; open ‘cmd’ in the current directory3 P$ X# V; Y9 L) P5 W
;8 S" U' H: u! a( U/ g/ t0 R
#c::
$ @5 \: x4 K2 ^9 f+ h OpenCmdInCurrent(): C( ^) ~) `# T! p
return
! A) \! q/ G) R #IfWinActive
0 i0 u4 _( s& S ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.% o7 U4 {4 Q$ }% @( \
; Note: expecting to be run when the active window is Explorer.
% ]( G# r s) g5 W0 R3 d9 g) B ;% g8 k- k, h& Z, e. h
OpenCmdInCurrent()
4 k/ P8 J- B: @( N% R8 q& g {
& N1 @4 m! O; s6 B, { ; This is required to get the full path of the file from the address bar
2 `, D5 ]3 f9 G' Q. O! C WinGetText, full_path, A
; n4 n4 r \- C: J ; Split on newline (`n)4 U: Y! H$ h0 O1 J# `
StringSplit, word_array, full_path, `n$ _1 O3 v9 e# S8 U! O3 `; J7 ]
; Take the first element from the array
# W6 s \* a/ r1 [+ [7 @ full_path = %word_array1%: a7 [0 u7 ~& h( D+ h7 t! h
; strip to bare address2 Y( w; m& W7 P+ ~7 w8 Y6 J* A
full_path := RegExReplace(full_path, “地址: “, “”) n7 I6 |) p1 K
; Just in case – remove all carriage returns (`r)* A+ Z0 ~( P1 \2 f
StringReplace, full_path, full_path, `r, , all
) K! n+ v3 t, J, a IfInString full_path, \
7 L/ u6 h# ], m0 ]" G {/ N$ l8 @& y5 \1 o/ a" G
Run, cmd /K cd /D “%full_path%”0 K9 q4 n& ?" S. u8 \5 g
}
, u/ A5 F0 c2 F" K) {- J8 n else6 ^ `: g& i# R# F" g: q0 T
{
- v3 S# H0 V! X0 J Run, cmd /K cd /D “C:\ ”
8 U3 e7 T! |: h* V }4 f" ?6 T; y1 g# j& R0 n+ a: v0 h
}
# I* w5 B% ]- U" u$ j1 g 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
: J$ M' l b/ R: p* @ 这段小代码肯能有两个你需要修改的地方+ Q6 o+ o$ q% w4 @6 a% L% l$ u
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
( o* C" ^. s5 T, P( h" @- w S 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
& f4 g8 ~ q3 O. W, h) `+ p |