此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。1 @0 S5 I% U7 D
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。8 r' k6 k+ R* V" u; i Y5 i
方式一:" m+ f* G6 a* G% E; b
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,$ n5 m5 K2 q# b
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和7 J' z/ |& t6 o& H; S; v* v
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
1 h/ U) o6 D' O( a 方式二:+ A$ f% @% t; A# C- E5 H, C4 B
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:$ N7 H, X$ m8 n1 y" ?
SetTitleMatchMode RegEx
) K8 ^3 N! D1 m+ z5 h7 I& a return) s. ?- U. Y' @, s
; Stuff to do when Windows Explorer is open
! {& g8 W3 m! L; x' a ;/ Z' u" z* @7 g9 {- z6 y# r8 o, \( j
#IfWinActive ahk_class ExploreWClass|CabinetWClass2 `/ A0 O: u9 g; _9 Z/ ?3 ?+ ]
; open ‘cmd’ in the current directory
% ? k; } y: Q& m4 L ;
3 g L, G* Q6 ^! g* X/ }! k ~ #c::7 A0 X7 I/ B. n( {4 g. q; M
OpenCmdInCurrent()
& U3 T! O$ {8 s$ v4 ^ return
0 k9 p0 @- p& a3 n #IfWinActive
0 R5 i2 a! |# Z: U2 v ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.( X# E5 B' i. O1 J T0 S
; Note: expecting to be run when the active window is Explorer.! N$ t2 r! \4 C$ R& Y9 _
;
9 Z4 d/ s2 z/ q0 L- h. X OpenCmdInCurrent()) e' _# } ]+ v/ S- M$ f+ }
{
( x0 G: T& l' S( \2 B; Q' z' f ; This is required to get the full path of the file from the address bar1 a4 f W% f- A6 F$ e1 ~! V
WinGetText, full_path, A2 ]/ s) V+ q$ t, y' b, C
; Split on newline (`n)
( H3 g, ~! r3 P9 j, Z' l StringSplit, word_array, full_path, `n. J0 S6 r" T D' V: M
; Take the first element from the array6 p" d1 _+ b4 d4 {. E6 K( B0 F. Q/ J
full_path = %word_array1%
' [; s0 |% j; m; Z4 B0 P ; strip to bare address
) ^7 U# s( ?' t! w5 G9 b full_path := RegExReplace(full_path, “地址: “, “”)$ a: G( V5 M. m2 @
; Just in case – remove all carriage returns (`r)' M8 I8 Y" l, C- J0 v+ M
StringReplace, full_path, full_path, `r, , all0 g. o: Q# Y j; i3 g! w
IfInString full_path, \
3 L6 X' X" U6 {! H# n$ B {
! I0 i0 B/ d( b7 C4 |( b Run, cmd /K cd /D “%full_path%”
$ ?: @) w! _% n: L7 F }0 M: _5 A( q# o# r7 B% q
else
! m5 x" X# d' S) ^ {$ S0 \9 S3 f8 C/ E! J$ [
Run, cmd /K cd /D “C:\ ”
; v6 O% F0 j1 |' _ }
9 J' a% }% c/ S- e3 C/ L* Q: C$ d }5 \/ J7 s. l; e- Z8 E
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
$ C9 ~, q0 C; y6 V* D 这段小代码肯能有两个你需要修改的地方
3 q' _2 m+ {) p" F' Z 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键' g+ v! G. e% S
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
+ t2 r+ Q o0 B$ S; e1 j |