IE COM get active tab
Posted: 20 Apr 2017, 02:44
How to get an active IE tab if there is 2 or more tabs With the same name? It's easy to get one With uniq name, but how about the same name? If I use the code bellow, it Works if there is only one Tab With that name, but if there is 2 Service Tabs, then the code doesn't work (I need that it Works on the active "Service" tab.
Code: Select all
pwb.Visible := True
pwb := IEGet("Service")
Loop{
sleep 100
one := pwb.document.getElementById("contentIFrame0").contentDocument.getElementById("IFRAME_EditTask").contentDocument.getElementsByTagName("DIV")[48].innerText
if (one <> "some text"){
pwb := IEGet("Service")
one := pwb.document.getElementById("contentIFrame0").contentDocument.getElementById("IFRAME_EditTask").contentDocument.getElementsByTagName("DIV")[48].innerText
sleep 100
}
}until (one = "some text")
msgbox %one%
Return
IEGet(Name="") ;Retrieve pointer to existing IE window/tab
{
IfEqual, Name,, WinGetTitle, Name, ahk_class IEFrame
Name := ( Name="New Tab - Windows Internet Explorer" ) ? "about:Tabs"
: RegExReplace( Name, " - (Windows|Microsoft) Internet Explorer" )
For pwb in ComObjCreate( "Shell.Application" ).Windows
If ( pwb.LocationName = Name ) && InStr( pwb.FullName, "iexplore.exe" )
Return pwb
} ;written by Jethrow