此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
3 q5 @% e9 P/ G" _( r: x 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。) _. V) F& H8 g% s* b4 m6 i0 d
方式一:7 J" R& O; u" O3 y8 q/ t" e5 Z
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
% V( z2 n' `, c& ?9 X5 S7 } 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
7 [5 ?6 W3 }2 T/ I# w4 v HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。7 g' f: T( l7 g' w: O) K( [
方式二:& Q* a* Q; m* V. E
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:; a3 e/ ~7 v% F0 j- ?$ q/ x
SetTitleMatchMode RegEx
/ i8 B; J+ O; T, V% o return
& X% O2 Q. H( b* u9 H ; Stuff to do when Windows Explorer is open
$ y. B; v8 r- l ;
/ |' j, f6 b+ {% J: ] #IfWinActive ahk_class ExploreWClass|CabinetWClass2 M7 D8 x7 H! K! E
; open ‘cmd’ in the current directory. m; S6 e- ]6 s% e; o" j* E
;
8 \! [1 j: V6 n0 G: X1 p. G- h #c::
+ f9 C# n* ^+ K5 p$ n0 H OpenCmdInCurrent()6 u, o7 D2 z q+ b2 V6 [
return
, i# G" [) P2 W5 X! [" o! m #IfWinActive) J: V# L7 K' L& \2 J, i
; Opens the command shell ‘cmd’ in the directory browsed in Explorer. \7 D+ e0 ^8 x( K' H, t s2 E, P
; Note: expecting to be run when the active window is Explorer.# x$ L2 `5 Y" w
;
$ r& e1 \) z0 _9 {$ l6 }) a OpenCmdInCurrent()
3 @* ~4 _# u" _- a0 F {
1 `1 M7 ]) `- M ; This is required to get the full path of the file from the address bar0 k0 P# Y( O& R1 P6 L
WinGetText, full_path, A
/ ]/ U8 n5 O+ p" {# r% P( I ; Split on newline (`n)' b$ S4 M0 A! ?
StringSplit, word_array, full_path, `n
w2 f7 g7 H* K3 _ ; Take the first element from the array
2 }; I! R8 G& ~' t" S, A& h$ {: c full_path = %word_array1%! b K" y2 v9 O
; strip to bare address
& Y$ W4 R. P t full_path := RegExReplace(full_path, “地址: “, “”)0 X( I3 _4 x& R3 Q. d
; Just in case – remove all carriage returns (`r)5 u2 [' h& s' b" v4 _" U, j8 T
StringReplace, full_path, full_path, `r, , all5 d) x+ H& |) N* b- n
IfInString full_path, \4 Q: z0 {' `% L/ I
{
4 \' T- M4 ?! @1 a- O$ l, r; F Run, cmd /K cd /D “%full_path%”
; l. x. |) {' Z) |1 W }
% Q% ]) q" M8 W1 o else# V; C2 s! U, ^" N
{
# F# G$ \( s* [4 G3 @5 \ Run, cmd /K cd /D “C:\ ”
: i8 ~0 Y- P* P7 K* i( @ }% H. a7 \2 r0 C5 N+ a# ^
}/ F7 I+ Y2 c* O) I
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。& s; x' {' ^" V% [9 w6 D
这段小代码肯能有两个你需要修改的地方
+ w* L/ N+ o% P1 O+ x, _" c 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键0 n8 ?( j) Y6 \( z6 J
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “* \% i# B, w# o. l4 }
|