此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
/ V$ Q: q3 k' [ 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。& Z; ?' L/ `. C2 g, C
方式一:
1 v, n2 f* [. U9 m0 J4 ~( } k 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
: `* [2 B. z% g! s 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和' v7 z) i; y7 V" r
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
! s; i4 n" Q w7 r5 t) S 方式二:) [. e/ p0 c: g- Z; B/ e
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:1 k. m! [' _8 B. b8 N# p! @
SetTitleMatchMode RegEx
4 z2 a+ T3 l% I* v return! S% u" ]$ R5 L5 p: `: J
; Stuff to do when Windows Explorer is open7 e& K" v2 @& h# e$ ~
;
O, |( n' R9 l# Z) s/ O. e9 | #IfWinActive ahk_class ExploreWClass|CabinetWClass
/ Y( g2 v; [4 H- z! U, d; p ; open ‘cmd’ in the current directory
0 |0 p) x1 s3 {: ]7 g5 m; l ;
% d( O$ b C" D3 s4 Y* j #c::
& u' X! w6 R1 M, k& L6 p! ] H# I OpenCmdInCurrent() W! Y$ [+ H) }9 M% X
return. ~6 U" q1 }: K5 X5 R: T! e
#IfWinActive8 c0 @0 t7 v* b1 o) r
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
0 p( a; g( \6 s- ]0 x ; Note: expecting to be run when the active window is Explorer.
, m6 c" W* ~) i6 M ;! |. A2 |; T1 _0 m9 g% a0 q
OpenCmdInCurrent()& g I& V0 J) ^9 m
{% j, ]; x: _2 |0 }
; This is required to get the full path of the file from the address bar8 P7 Y/ _5 ^# x9 t
WinGetText, full_path, A
& W/ k8 o2 ]% d* B$ j* ]( u5 Y# I ; Split on newline (`n)
9 [) |9 |$ J' t9 m0 A R StringSplit, word_array, full_path, `n
9 o X* m" U4 |% @ ; Take the first element from the array
% M, S- W& Q- D3 |; o* ~ full_path = %word_array1%9 q% v$ t8 e" y5 K
; strip to bare address+ x8 L5 ^+ ~5 P1 y2 L
full_path := RegExReplace(full_path, “地址: “, “”)4 `1 v3 z1 b1 E. p2 x, E
; Just in case – remove all carriage returns (`r)
/ p: t* Z. `. V) j: V& @, S; I4 f6 X StringReplace, full_path, full_path, `r, , all" P5 W. n x) ^ l7 m6 v* U8 }3 ~
IfInString full_path, \, v% V) f ]. c" x$ Z! F
{: L( W8 Q z0 G& b' b8 k1 n
Run, cmd /K cd /D “%full_path%”, X8 r. e; E9 B- d
}* ^5 P! Q/ y$ E7 }! M' W
else; z$ p3 |) u! n
{
( z b# w' P3 `' T* i$ s: T Run, cmd /K cd /D “C:\ ”+ l8 b& @8 ?* a& K
}! [3 y- o- j; A6 E3 \: \
}
* J S6 g% H Y0 D 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。# r& \: I% K' t1 m6 z* F/ d& i- Q
这段小代码肯能有两个你需要修改的地方
& L6 e5 E- n7 Y' M3 y5 s& d% u 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
( F5 L+ V+ R( F1 K0 E% I8 n9 a 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “% x% \; z9 I* B8 c5 ~! l) J/ H
|