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.

Check if URL is Open in IE


searchurl =  "http://www.winbatch.com"

objShell = CreateObject("Shell.Application")
objInstances = objShell.windows
objIE = 0
If objInstances.Count > 0 ; make sure we have instances open.
   ForEach objIE In objInstances
      sName = StrLower(objIE.FullName)
      If StrIndex( sName, 'iexplore.exe', 1, @FWDSCAN ) != 0 ; internet explorer not windows explorer.
         If StrLower(searchurl)== StrLower(objIE.LocationURL)
           ret = AskYesNo( "Found instance of Internet Explorer mathinc your url ":objIE.LocationURL, "Would you like to view html?" )
           If ret
              objInstances = 0
              objShell = 0
              Break
           EndIf
         EndIf
      EndIf
   Next
EndIf
If objIE == 0
   Pause('Notice', 'Unable to locate any running instances of InternetExplorer')
EndIf

objDoc = objIE.Document
objMainhtml = objDoc.GetElementsbyTagname("HTML").item(0)
Pause('Webpage data', objMainhtml.innerhtml)
objMainhtml = 0
objDoc = 0
objIE = 0


Alternative way for WinXP or older

searchurl =  "http://www.winbatch.com"
;Check to see if ClassID installed
myShellWindowsClsid="{9BA05972-F6A8-11CF-A442-00A0C90A8F39}" ;ShellWindows
myShellWindowsKey="AAA.TEST\CLSID"
If RegExistValue(@REGCLASSES,myShellWindowsKey) == @FALSE
   RegSetValue(@REGCLASSES,myShellWindowsKey,myShellWindowsClsid)
   If RegExistValue(@REGCLASSES,myShellWindowsKey) == @FALSE
      Message("CLSID Not installed.","Need Admin access")
      Exit
   EndIf
EndIf

SWs=ObjectCreate("AAA.TEST",1)
count=Sws.count
browserdoc = 0
For xx=0 To count-1
   windowobject=Sws.Item(xx)
   If windowobject.TopLevelContainer
      lu = windowobject.LocationURL
      ;only grab MSIE windows
      If StrIndexNC(windowobject.fullname, "iexplore.exe", 1, @FWDSCAN) > 0
         If StrIndexNC(lu,searchurl, 1, @FWDSCAN) > 0
            ;;Grab this windows document object handle
            browserdoc = windowobject.document
            Break
         EndIf
      EndIf
   EndIf
   windowobject = 0
Next

If browserdoc
   Message("Url checker","The url is open")
Else
   Message("Url checker","The url is NOT open")
EndIf


;Close open objects
If browserdoc !=0 Then browserdoc = 0
SWs = 0

Article ID:   W16630
File Created: 2011:07:15:09:24:32
Last Updated: 2011:07:15:09:24:32