妙用SendKeys自动上网并登陆博客

将下面的脚本复制到一个文本文件中,并将其文件名命名为:自动登陆.vbs,然后将拨号软件及本脚本一起复制到程序——启动项中,就可以实现自动拨号上网,并登陆到博客上。<?xml:namespace prefix="o" ns="urn:schemas-microsoft-com:office:office">?xml:namespace>

代码如下:

Set wshshell=CreateObject("wscript.shell")

wshshell.AppActivate "连接 MAE-301U 拨号连接"

wscript.Sleep 20000

wshshell.SendKeys "{enter}"

wshshell.Run "iexplore"

WScript.Sleep 2000

wshshell.AppActivate "hao123网址之家---实用网址,搜索大全,尽在http://www.hao123.com/ - Microsoft Internet Explorer" '引号中的内容修改为你的浏览器打开后标题栏中的内容

wshshell.SendKeys "%d"

wshshell.SendKeys "http://passport.baidu.com/?login"

wshshell.SendKeys "{enter}"

WScript.Sleep 2000

wshshell.SendKeys "此处修改为博客帐号"

wshshell.SendKeys "{tab}"

wshshell.SendKeys "此处修改为博客密码"

wshshell.SendKeys "{enter}"

'wshshell.SendKeys "%d"

Vbs脚本常用的编辑器当然是notapad,不过这个编辑器的功能当然实在是太弱了一点,其实有很多的专用的脚本编辑器可以大大方便vbs脚本的编写。我常用的有两种:

1VBSEDit汉化版

2primalscript汉化版,可以对30多种脚本进行编辑