WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

OLE with MSIE
plus

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

OLE Event Examples


Sample 1: Wait for Button Click Event

#DefineSubRoutine startMSIE(url)
   Browser = ObjectOpen("InternetExplorer.Application")
   Browser.addressbar = @FALSE
   Browser.statusbar = @FALSE
   Browser.menubar = @FALSE
   Browser.toolbar = @FALSE
   browser.visible = @TRUE
   browser.navigate(url)
   ; wait until page loads...
   While Browser.busy || Browser.readystate <> 4
      TimeDelay(0.5)
   EndWhile
   ; setup the document object...
   browserDoc = Browser.Document
   all = browserdoc.all
   Return(browser)
#EndSubRoutine

#DefineSubRoutine WaitForBrowser()
   While Browser.busy || Browser.readystate <> 4
      TimeDelay(0.5)
   EndWhile
   Return
#EndSubRoutine

#DefineSubRoutine MyButtonClick()
   msg = "button was pushed"
   Display(1, "Debug", msg)
   Return
#EndSubRoutine

#DefineSubRoutine ExitLoop()
   msg = "exit button was pushed"
   Display(1, "Debug", msg)
   loop = @FALSE
   Return
#EndSubRoutine

url = "about:blank"
br = startMSIE(url)

br.document.writeln(`<input id="dabutton" type="submit" value="Click Me"/>&nbsp;<input id="exitbutton" type="submit" value="Exit"/>`)

DaButton = br.document.all.item("dabutton")
objecteventadd(DaButton, "onclick", "MyButtonClick")
XButton = br.document.all.item("exitbutton")
objecteventadd(XButton, "onclick", "ExitLoop")

loop = @TRUE

While loop
   TimeDelay(1)
EndWhile

Message("Debug", "Loop Finished...quitting")
br.quit

Exit


Sample 2: Take care of someone closing MSIE while your app is still running

Winbatch Version: 2005E -- Script by Jay Alverson

#DefineSubRoutine MSIEQuit()
   ret = AskYesNo("Are you sure?","Do you really want to stop this process?")
   If ret == 0 Then Return
   ;maybe add clean up code here?
   Exit
#EndFunction

url = "about:blank"
Browser = ObjectOpen("InternetExplorer.Application")
Browser.addressbar = @FALSE
Browser.statusbar = @FALSE
Browser.menubar = @FALSE
Browser.toolbar = @FALSE
browser.visible = @TRUE
browser.navigate(url)
; wait until page loads...
While Browser.busy || Browser.readystate <> 4
   TimeDelay(0.5)
EndWhile
; setup the document object...
browserDoc = Browser.Document

browserDoc.writeln(`Close this window using the system menu in the upper right hand corner.`)
objecteventadd(browser, "onquit", "MSIEQuit")

loop = @TRUE
While loop
   TimeDelay(1)
EndWhile

Message("Debug", "Loop Finished...quitting")
browser.quit
Exit

Article ID:   W17182
File Created: 2007:07:03:14:28:36
Last Updated: 2007:07:03:14:28:36