VBScript中调用IE浏览器
- 一、 Internet Explorer.Application
- 二、 WScript.Shell
一、 Internet Explorer.Application
a.vbs文件内容如下:
StartURL = "https://www.baidu.com/"
set IE = CreateObject("InternetExplorer.Application")
IE.Visible = true
IE.Navigate StartURL
双击执行“a.vbs”文件,即可调用浏览器,并访问网址
二、 WScript.Shell
Dim Wsh
Set Wsh = WScript.CreateObject("WScript.Shell")
On error Resume Next
objeShell.Run("http://www.baidu.com")
下面的代码就是自动打开百度并输入服务器之家进行搜索的代码
Dim wsh,ie
Set wsh = CreateObject("wscript.shell")
Set ie = WScript.CreateObject("InternetExplorer.Application")
URL = "http://www.baidu.com"
code = "服务器之家"
ie.visible = true
ie.navigate URL
WScript.Sleep 1000
wsh.AppActivate "百度一下,你就知道" ' 引号中填浏览器最上面的标题
wsh.Run "cmd.exe /c echo " & code & "| clip.exe", vbHide
wsh.SendKeys "^v"
wsh.SendKeys "{ENTER}"
用vbs实现网站自动登录
Dim wsh,ie
Set wsh = CreateObject("wscript.shell")
Set ie = WScript.CreateObject("InternetExplorer.Application")
URL = "http://www.baidu.com"
ie.visible = true
ie.navigate URL
WScript.Sleep 1000*5
wsh.AppActivate " " ' 引号中填浏览器最上面的标题
WScript.Sleep 1000*1
wsh.SendKeys "账号" '引号中填账号
WScript.Sleep 1000*1
wsh.SendKeys "{TAB}"
WScript.Sleep 1000*1
wsh.SendKeys "密码" '引号中填密码
WScript.Sleep 1000*1
wsh.SendKeys "{ENTER}"