Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.
Keywords:
Access Current New Get Instance IE Window Shell.Application Internet Explorer innerHTML
So, you want to access a pre-existing instance of the internet explorer. Code like this will allow you to get the document handle for the open session
It uses the Shell Windows Object to obtain a list of instances.
Once it finds all the iExplore, it'll loop thru the collection. You'll have to inspect each one's .locationURL property to see which URL it's at. Then once you have the correct instance of Explorer, you can proceed from there.
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. ret = AskYesNo( "Found instance of Internet Explorer ":objIE.LocationURL, "Would you like to view html?" ) If ret objInstances = 0 objShell = 0 Break 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 = 0Accessing the frames:
Once you retrieve the document object of the new window then use the frames Collection to get information about the frames.
In looking at the MSIE object documentation at http://msdn.microsoft.com/workshop/browser/webbrowser/reference/objects/InternetExplorer.asp?frame=true it seems to indicate the document property can be used to access to the contents of the HTML Document Object Model (DOM) of the active document(HTML page).
OLD WAY ( Only works up to Windows XP)
It sets up a registry entry in your PC so that you can attach to Windows Explorer windows (MSIE = Windows Explorer for the most part)
Once it finds all the Explorers, it'll loop thru the collection. You'll have to inspect each one's .locationURL property to see which URL it's at. Then once you have the correct instance of Explorer, you can proceed from there.
;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 <p> SWs=ObjectAccess("AAA.TEST",1) count=Sws.count Message("Count",count) <p> For xx=0 To count-1 windowobject=Sws.Item(xx) lu = windowobject.LocationURL Message("Debug", windowobject.HWND) ; If StrIndexNC(lu, "file://", 1, @FWDSCAN) != 0 ;this would be a IE window Message("Found IE Window",lu) Message("Debug", StrCat(windowobject.name, @CRLF, windowobject.fullname)) ; <----- this seems to be more clear doc = windowobject.document ; EndIf Next
Article ID: W16628
File Created: 2011:07:15:09:14:12
Last Updated: 2011:07:15:09:14:12