此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。" C' X! g, M8 v2 f4 M
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
5 t( x8 H" {+ ?, r. A. L# [9 L* q 方式一:7 q$ ~9 Z% U, l0 R) U$ N: P$ O& r
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,1 e; Q% R3 l& T5 ~0 w3 N
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
' \/ a' |4 J; O+ y0 K' w HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。# B6 D% d2 y! \/ b( K
方式二:5 S9 d' p" \# r
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:, P9 }9 ^: q6 x4 {( D
SetTitleMatchMode RegEx
8 s( w z% L# |$ @3 [0 ^9 A/ x return
* @6 {0 I, {8 w( Z- ]/ K1 t ; Stuff to do when Windows Explorer is open, f! t; Y! g, L4 U! Z5 Q
;2 ~# S6 [" {7 f& U; [2 w6 a0 L5 Y) }
#IfWinActive ahk_class ExploreWClass|CabinetWClass
( w. t$ a" b- Q* G- ]( s& y ; open ‘cmd’ in the current directory
1 @6 @/ N8 o# D1 C9 W. v3 ~1 { ;
, a9 s! m: m6 F* J7 S: l# \' B #c::) C: u: o. \8 \# A( v! L( x
OpenCmdInCurrent()7 v: Y- X5 T6 H5 w" g7 a0 N+ }5 m
return# W a4 o! k) {5 t s
#IfWinActive
# e& ? _, T! w& m# \, ^7 U& B ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
( X1 T) a, R5 Z6 S ; Note: expecting to be run when the active window is Explorer.
4 O! S5 z M @+ J6 m1 } ;
7 U$ }% Z. o: N h- P, C# X OpenCmdInCurrent()5 E- ]6 j* t' E) S) u
{# F: F. y, L A0 h! R+ e p- q
; This is required to get the full path of the file from the address bar
5 g7 |& K5 T; Z/ _ WinGetText, full_path, A7 h2 l+ E9 x) A: l% A
; Split on newline (`n)6 N' s; ^ n9 t8 m' v+ e6 v
StringSplit, word_array, full_path, `n1 X! K3 D( X2 g
; Take the first element from the array
1 U! c$ r, ~6 y9 a, o2 l' r full_path = %word_array1%- C" H+ A c/ c7 @# n
; strip to bare address
- l( O+ C) x& f0 Z* G- \% M4 Y full_path := RegExReplace(full_path, “地址: “, “”)+ }: l' a V6 o. i3 P
; Just in case – remove all carriage returns (`r)4 Z1 B7 I) N, n2 |8 P+ z
StringReplace, full_path, full_path, `r, , all
6 m' q1 ~: Y( U% H; G- ]: G IfInString full_path, \% I' x5 t9 W8 C
{
7 N& d" d7 k: w K Run, cmd /K cd /D “%full_path%”/ t2 @% o# h) \( d. J8 W
}
# N8 x& y; [5 k, m else
/ c; M0 g9 T) J% t" j8 h9 J a {
% p# Q% T. n, H5 E5 W9 \: D Run, cmd /K cd /D “C:\ ”) p+ e+ d% x1 r; g# N; X
}5 t4 k; T/ \) h" F# i- R
}
; h5 {& i8 w5 T2 F n3 V: k' f) G 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。# M# H( n* s8 \
这段小代码肯能有两个你需要修改的地方8 r7 N; w4 N2 H+ ~
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键% u( m H& J$ a8 Z6 E L
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “: Q5 X9 z. L4 V. a9 p$ d
|