此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。& ~( [* e/ _3 x8 R7 O% I) C
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。4 Z7 p" T9 Z( ^" d$ v
方式一:4 X% T7 f& |8 L0 c
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
7 p! _* B+ i% n, T' H. b2 H 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和5 X; b* C, h/ ] _8 v. B& _( e
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。0 z# t* n E; I$ G- P
方式二:( n6 ?: W2 [! A# o$ R+ S- Q; N2 ~
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:9 o0 j: p9 M6 u$ c2 W. c( s- C" o
SetTitleMatchMode RegEx; }4 R) E; G/ f6 s
return
% |5 f% Y! o: Q$ x* _3 D0 A ; Stuff to do when Windows Explorer is open
2 b+ N& |* N# j" b. W ;
2 y& a7 B: N. S* [1 q #IfWinActive ahk_class ExploreWClass|CabinetWClass
: K* h* v- M9 b( t ; open ‘cmd’ in the current directory
0 S2 P; k7 O8 a ;* _" m+ a4 ]- w1 f4 x9 }0 ^
#c::; n1 _6 H) l( i% I, Q$ l0 w
OpenCmdInCurrent()* ]. y+ L7 Q( c1 l0 C# @
return
! ?2 B/ s# A+ p @ #IfWinActive
! s/ ~% @$ L1 U# q. {5 z+ y ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
0 _% [( T1 _, [, v* d- z5 m1 Z ; Note: expecting to be run when the active window is Explorer.0 d: T! b" J7 M, p# u$ `0 ]
;
) m/ U9 x" u2 Z" |: ]; G OpenCmdInCurrent()
0 J2 N2 |' S! c( P {
! \. J# T, O: J8 d% z4 | ; This is required to get the full path of the file from the address bar
6 z0 a4 G8 O2 U9 n. H WinGetText, full_path, A( W0 ~+ g; G2 P1 t6 X$ Z
; Split on newline (`n)5 R. j: o# |, c$ ?6 k
StringSplit, word_array, full_path, `n0 u; f% f2 p% D; G% @/ f
; Take the first element from the array
: Z% l. E6 N# a" L4 V s( u full_path = %word_array1%
. S/ {+ P/ S$ _3 P* r ; strip to bare address2 G" x- E$ D, \) J4 J- k
full_path := RegExReplace(full_path, “地址: “, “”)
, f4 G. d8 D( m ; Just in case – remove all carriage returns (`r). S- F0 G5 z; _& D! S8 e0 d$ o4 e
StringReplace, full_path, full_path, `r, , all% t b% n/ @, S6 P: D9 r: [
IfInString full_path, \2 a; Z* D4 `. r, Q0 G
{" `; q- |) f- B2 r7 _$ h; u
Run, cmd /K cd /D “%full_path%”1 h5 l9 I$ n+ {
}8 ]) ]7 @1 \! p7 X9 }, P" s* K( Z
else
" ~ c8 G- q. ], D* D, o' E {
' z, b" \" M9 E9 w6 E, Y4 X7 l. w Run, cmd /K cd /D “C:\ ”
0 r/ b5 n' q4 J8 s( t }
$ C/ h8 p4 e1 \ }6 A# E; O9 E5 K6 B" G1 S
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
o# P$ Q# j5 z7 F' y3 q 这段小代码肯能有两个你需要修改的地方
: e, w6 y3 ~) ?( h0 I( c 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
& g' c: c3 |, N* R$ @! i, E 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
3 o. n. N) R( x |