此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。! n6 X/ J; ? C5 k9 L% [% x/ s
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。7 [ x) ~( ~) r- j2 L( @) y8 X, D
方式一:
0 m; J! S) X' F9 Z. a$ z; U$ C 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,, ?+ P' c: ~$ U" i3 l, E* m$ E2 R, Q
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和/ ^+ Z3 b* {! L$ B8 p
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。2 T6 c1 ~1 Q+ A% i/ J
方式二:
3 G# t2 g6 V; O `4 I& w N 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:- v* _( N8 g1 t r0 M. s/ P
SetTitleMatchMode RegEx
) o7 F6 H: `( U N4 W0 i1 l return4 L2 K8 d( a6 g) D+ }, w0 w3 Y
; Stuff to do when Windows Explorer is open
% ? L f0 ]! s- B7 l5 a9 y ;
- `% T! U8 Y- |, `7 u #IfWinActive ahk_class ExploreWClass|CabinetWClass
* ^( ]% B3 u5 r+ N+ g: s ; open ‘cmd’ in the current directory
8 N4 d' L2 X! T( G ;
: R7 p5 y. Q$ e+ G. ~; C #c::
4 ]4 T( M$ P, F OpenCmdInCurrent()8 p2 d ?0 \3 M9 |+ }' A# B
return
- G3 Y. K& n0 Z$ j% H* I' m #IfWinActive
1 S2 U2 ]" P7 I- z; m2 a) a% Y ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
) T, y/ n& Z8 V0 p3 R( G ; Note: expecting to be run when the active window is Explorer.
7 t% A0 n4 i% p6 I+ m ;
. ~8 S$ ]1 F+ W6 q6 [5 M6 b% U OpenCmdInCurrent()
4 } s( h- d7 o+ Q2 i5 V u0 i {- @! c X4 ~; L0 s3 T( r
; This is required to get the full path of the file from the address bar
. S2 C! m3 s3 O0 b& a WinGetText, full_path, A
) Q6 G7 J; U& q" E ; Split on newline (`n)
* {2 M; V, ]7 a/ i0 a& k StringSplit, word_array, full_path, `n$ B& n) v2 i' x8 f* J
; Take the first element from the array. j* P* b& _. c. [
full_path = %word_array1%4 E8 I! J$ |+ L) J' T+ O8 x; N8 W
; strip to bare address
; O( p( N7 a% z0 ^( [: O" ~ full_path := RegExReplace(full_path, “地址: “, “”)( O. @: w! \. z5 E
; Just in case – remove all carriage returns (`r)
+ H; Z K, s8 Y5 a StringReplace, full_path, full_path, `r, , all
2 @2 r& A7 a3 \% u" R) {4 w IfInString full_path, \
) r" X# y! Z# a {
# Z: X1 W9 O% h1 H4 R; B# ~8 a t5 Q Run, cmd /K cd /D “%full_path%”* }; Q* O) X7 ^* Q. u) n; ^1 W9 z
}% @$ \2 k, x1 z* y t
else
( P/ s, @& F' l {2 s, h1 u" a7 G* b: b" [6 w
Run, cmd /K cd /D “C:\ ”) N) a" \* ~# a% ^/ n. s# T( m/ k
}5 p* L: y( g/ @! ~: a; v1 J
}
! J* y8 ]6 ?+ u# i0 T9 r 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。0 d4 }3 c! M/ I5 M
这段小代码肯能有两个你需要修改的地方
, V( @0 T$ {2 _! h 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键( {0 s( h0 _, T3 i( B$ a- u
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
: c& K9 b- t, g; k/ m# G% E |