脚本启动后可按照设定时间间隔刷新IE当前页面,用于完成某些特定的任务。若IE实例不存在,则退出。
time=<刷新间隔的秒数>
'Dim the primary objects.
Dim objApp
Dim objIE
Dim objWindow
Dim time
time = 1000*3600
'Set the primary objects.
Set objApp = CreateObject("Shell.Application")
Set objIE = Nothing
'Identify the IE window and connect.
For Each objWindow In objApp.Windows
If (InStr(objWindow.Name, "Internet Explorer")) Then
Set objIE = objWindow
Exit For
End If
Next
With objIE
.Visible = True 'Make sure to set the window of IE to visible.
Set objDoc = objIE.Document
Do While .Busy Or .readyState <> 4
'Do nothing, wait for the browser to load.
Loop
Do While .Document.ReadyState <> "complete"
'Do nothing, wait for the VBScript to load the document of the website.
Loop
Do While True
Wscript.Sleep time
objDoc.Location.Reload(True)
Loop
End With
'Clear the objects.
On Error Resume Next
objApp = Nothing
objIE = Nothing
objWindow = Nothing