ok got it to work although I had to wait for each tab to load 1st
Code: Select all
TabName = AutoHotkey - Windows Internet Explorer
Links := [ "google.com", "ahkscript.org", "autohotkey.com" ]
wb := ComObjCreate("InternetExplorer.Application"), wb.Visible := true
For i, Link in ( Links, wb_ := [] )
{
wb.Navigate2( Link, ( i=1 ? "": 4096 ) ), Wait( wb, 800 )
wb_[ i ] := WBGet( "ahk_id" wb.hwnd, i )
}
While ( CurrentTabName != TabName )
ieObj := wb_[ a_index ], CurrentTabName := wb_[ a_index ].LocationName " - " wb_[ a_index ].Name
Msgbox % ieObj.document.getElementsByTagName( "*" ).length " tags found on " CurrentTabName " tab."
return
ESC::ExitApp ; <-- Press escape to exit.
Wait( obj, int = 500 )
{
While !(rs~="4{" int "}\b")
{
rs .= obj.ReadyState
}
}
WBGet(WinTitle="ahk_class IEFrame", Svr#=1) { ;// based on ComObjQuery docs
static msg := DllCall("RegisterWindowMessage", "str", "WM_HTML_GETOBJECT")
, IID := "{0002DF05-0000-0000-C000-000000000046}" ;// IID_IWebBrowserApp
;// , IID := "{332C4427-26CB-11D0-B483-00C04FD90119}" ;// IID_IHTMLWindow2
SendMessage msg, 0, 0, Internet Explorer_Server%Svr#%, %WinTitle%
if (ErrorLevel != "FAIL") {
lResult:=ErrorLevel, VarSetCapacity(GUID,16,0)
if DllCall("ole32\CLSIDFromString", "wstr","{332C4425-26CB-11D0-B483-00C04FD90119}", "ptr",&GUID) >= 0 {
DllCall("oleacc\ObjectFromLresult", "ptr",lResult, "ptr",&GUID, "ptr",0, "ptr*",pdoc)
return ComObj(9,ComObjQuery(pdoc,IID,IID),1), ObjRelease(pdoc)
}
}
}
Still needs some modification to find tabs not created by the script.