此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。, h3 V: A! U% x& H' x
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
: f* s3 ~* E: W5 b+ F# y 方式一:. M8 b) N2 c: h, g4 R- w% ^
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,: m: ~) l* a3 \. i3 L' w+ u
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
1 z7 a3 Y5 i) Z HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。9 i. b% ~/ r. J% j# X8 E
方式二:
' Y" m* h( T# z4 P$ r5 k0 J 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
( r% L$ ? s+ ~4 X2 W6 t SetTitleMatchMode RegEx W4 u: ]) C( B0 c! X
return
) W: A' q8 G: l7 y ; Stuff to do when Windows Explorer is open9 M' |+ J/ Z8 D- E
;
! \) Q5 l. T# T# z- h n #IfWinActive ahk_class ExploreWClass|CabinetWClass
/ w9 h& ~# R1 g1 A ; open ‘cmd’ in the current directory5 {( T( f1 _% c
;, ]+ j6 g( j' I ?0 `
#c::8 O( E3 o. n0 T( {" S
OpenCmdInCurrent()
0 S% M& a2 q& s w* m$ Q return- t; k4 L' {+ f( V, Y
#IfWinActive
& Y7 @) z& t) _5 P ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.) ]+ f6 `5 q \) O3 r" x: u
; Note: expecting to be run when the active window is Explorer.4 u# d. x2 s7 W% W0 c" m) }
;# W4 q9 @+ z: ]- S2 {) d, j1 k
OpenCmdInCurrent()6 z" E% ]) ^! ?& H T
{
1 B0 e2 q% P9 `9 e ] ; This is required to get the full path of the file from the address bar t5 } [. l9 G S+ I' V
WinGetText, full_path, A0 V; i" q$ m4 S3 I: t' ]3 p
; Split on newline (`n)( g. p/ a- R& i0 ]* d. F
StringSplit, word_array, full_path, `n
8 W; U5 T5 m( f& s5 G6 R' h ; Take the first element from the array
+ _, t0 S" a5 S U9 E7 B& T full_path = %word_array1%
2 T! ^! x; Z& `- Y' g ; strip to bare address% {# q) m H$ {% z0 p
full_path := RegExReplace(full_path, “地址: “, “”)
: F; z4 f/ q- t4 L ; Just in case – remove all carriage returns (`r)
$ }1 {: e; K6 s4 R {9 H StringReplace, full_path, full_path, `r, , all
: }) y. U' z5 q- _2 L IfInString full_path, \
8 D9 F4 \# ], I' X& V* r3 u" ?( ~6 V {
6 U$ y y2 J' a7 }+ ? Run, cmd /K cd /D “%full_path%”! Y' h' S. i3 \6 {6 P
}6 Y5 v4 }% l0 d
else _4 z! _) C3 m, n1 [
{
0 E @5 E& f, c! W& \ Run, cmd /K cd /D “C:\ ”
. v' X( j* h& }: b# `# Z }; @- }4 W0 j4 Q/ |5 ~* }, g
}3 R; ^9 y I% o, z* q
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。5 C6 s2 d. I* z! M/ \9 r
这段小代码肯能有两个你需要修改的地方
+ ]0 [4 G: U: J d& ?% z 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
# k+ K+ R2 ?! ~+ S: @0 {( \, M- J 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
/ F3 d3 J4 m% ^+ p) i |