此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
. B$ H' a8 M/ ~# l 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
$ z1 f: f; M7 U' P* U* g* Y o' _ 方式一:6 W3 g. I" @1 g2 o! H# U6 W
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,% X: O4 L; i5 J6 W/ {. [7 \/ m
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
. X% g0 `9 [! @* ]6 Z: t HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
. H$ j4 E# G, I0 V$ p) q 方式二: \8 v- ~8 w2 z% s5 M8 _2 u& K" m% S& N
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:( C# o) I3 Y" c- k
SetTitleMatchMode RegEx
. U& |$ b8 A, {- ?5 s5 F; a% |: _6 m return
0 e7 ^' e. C- m& p ; Stuff to do when Windows Explorer is open
9 G1 o, L* b1 F. r, _7 ]" I ;
$ U$ n, a# t; I+ \7 T8 I #IfWinActive ahk_class ExploreWClass|CabinetWClass
4 m3 [7 U) D- V; y: t ; open ‘cmd’ in the current directory4 `" c) f5 `$ ~) K, ?
;8 l* J- @8 |% G! ~
#c::
; G5 ~& R- l1 w4 B2 L OpenCmdInCurrent()
: t" I2 {8 O. g1 A' l+ D return( ^* z0 K* Q; u; q
#IfWinActive# G; ^0 q4 g7 T' P7 Y. u
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
/ Q3 |2 P. D, @; C ; Note: expecting to be run when the active window is Explorer.5 m. E J/ {' l0 M6 E
;
9 ]* v) T' o& y0 L" t9 {; Q( s OpenCmdInCurrent()
! t2 x0 o$ Z ]. ]$ L/ y4 w {& B4 g7 ~( i& O7 A
; This is required to get the full path of the file from the address bar0 {+ @6 Q* F6 P5 G0 |4 I- K
WinGetText, full_path, A
' ]/ |" z5 u- J6 `7 L, g! Y5 t ; Split on newline (`n)
2 b+ b8 ~- V8 ^ v StringSplit, word_array, full_path, `n
+ Z* Z" ~2 F' M/ H( B' P ; Take the first element from the array
/ _1 f1 \! j1 }) b full_path = %word_array1%" b/ l+ a' ~/ x/ s6 l0 I, I6 s
; strip to bare address
; R% W! V" }% G. \4 P( v/ t* O full_path := RegExReplace(full_path, “地址: “, “”); }) v! H% M* p) p. {
; Just in case – remove all carriage returns (`r)* e7 G& F: ~$ f& }9 B
StringReplace, full_path, full_path, `r, , all5 X4 n, H, u3 C7 ]' i3 D" H
IfInString full_path, \
3 Q D8 L' A& d3 l7 a {
) R8 V7 q, t6 N' X. a$ C E Run, cmd /K cd /D “%full_path%”+ {* J% B/ f' a4 N8 G
}
) g6 Z' B9 O. _1 g+ p else
8 E3 L- G! ?! T: r {
' a2 s. q% I+ P( p4 } Run, cmd /K cd /D “C:\ ”
* P/ N( z& x M' C1 I }, ?, Q: b. Y6 T) j
}" |; h/ K! l# Y% E6 m/ X$ z0 }( R
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
# F5 i4 ^& [* A1 R! E( e0 ]& \( J 这段小代码肯能有两个你需要修改的地方
1 D' I: L. Q6 b! y! Q3 o 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键' Z$ `% O7 k: v) I
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “! j7 M" E& S4 o5 r" `7 A
|