woensdag 6 februari 2008

Accessing IExplore from VBScript

So you want to access a Iexplore window that's already opened and on the desktop. Here's some sample code (VBScript):

This code will give a msgbox showing the URL for every open IExplore window.

----------

Set objShell = CreateObject("Shell.Application")
Set IEWindows = objShell.Windows

Dim IEWindow()

ReDim IEWindow(IEWindows.Count)
Dim i

msgbox IEWindows.Count

For i = 1 To IEWindows.Count

Set IEWindow(i) = IEWindows.Item(i - 1)
Next

For i = 1 To UBound(IEWindow)

msgbox IEWindow(i).LocationURL
Next

----------

Now you know how to connect to a IExplore window you can access all controls inside by programming the DOM (Document object model). It's a fairly easy model, look it up, google is your friend! :)

Geen opmerkingen: