此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。3 W& u E6 z6 {) e9 o
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。. m& f4 C7 {) w6 T' U. B
方式一:
) l* ~$ m [2 ~5 ~5 Q 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
- t9 f- m* M; I1 E) } 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
4 o$ J& Y' g Q4 l* [! l2 W( ^ HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。- b% P: c H7 @7 r! y
方式二:
; D4 L/ m3 O* b& ]0 M 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
: ]0 T" e, M u/ n SetTitleMatchMode RegEx
- O W; J: V5 p3 X! p return
% X5 N1 B* \: R8 W" c, |" W& C ; Stuff to do when Windows Explorer is open
- h7 @% t9 Z3 r5 ^ ;
$ A# W$ \( L* o #IfWinActive ahk_class ExploreWClass|CabinetWClass
+ z/ U8 B9 H' k8 [5 V _ R ; open ‘cmd’ in the current directory
0 `7 `: ]0 A2 v; x ;, I/ f1 m( W0 G) F
#c::
7 @2 X0 Z" T6 L% K- M. j OpenCmdInCurrent()
1 J' O8 t& w( T' y, v return
: W9 d0 ~1 C; y2 b) i! M #IfWinActive0 u( q" M/ e4 v/ i3 V
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
2 S9 W/ ]1 b/ e- b: V# O9 R0 _" ~ ; Note: expecting to be run when the active window is Explorer.# @3 x0 n& T, V: l' E/ d
;4 c4 q! W/ Z. X) V' {5 s
OpenCmdInCurrent()
0 v% k% E* \) F6 ~7 y& O {
; N% @4 M* B) x4 N' Z ; This is required to get the full path of the file from the address bar6 v) n' n) Q; C
WinGetText, full_path, A$ u' o. Q$ i/ V
; Split on newline (`n)
) B E) p# c( o F ] StringSplit, word_array, full_path, `n5 ?! s; b ^* @: m
; Take the first element from the array
9 n0 H8 A O) E% F5 R% }' V% I full_path = %word_array1% t1 x" q' {. @- L, n6 s
; strip to bare address
3 d1 b2 ]. t( u+ L# X" A4 D, _ x full_path := RegExReplace(full_path, “地址: “, “”)
" K) O/ H- S) M, @0 F ; Just in case – remove all carriage returns (`r)
s4 G) t* V3 B } StringReplace, full_path, full_path, `r, , all, P8 u M& y' _
IfInString full_path, \0 {9 v7 P9 k1 G8 v, ]
{0 \0 A+ L2 \% _
Run, cmd /K cd /D “%full_path%”$ r9 b1 c( y+ T' a% Q; K1 A% y8 ?
}( A1 i% r- P9 ?6 L, s3 N/ p
else+ g5 |9 _" ]+ A G
{
) @4 K) | T4 X+ z Run, cmd /K cd /D “C:\ ”, A, R [4 E, v; A
}) q4 o* ~ g8 V z5 a
}# I0 I5 E5 W7 u$ r( ?$ h0 o& Q
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
2 ], Q- O+ R+ i; p3 d 这段小代码肯能有两个你需要修改的地方: d: X; _9 O4 D
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
' O% M1 z$ [+ i 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “) Y: `% b4 A ~: [/ L9 }
|