... the WBGet() function has indeed performed well - but in my experience - has been limited to returning the DOM for the active foreground window under Windows 7 with IE9. This in sharp contrast to the IEGet() function which has been returning any available window or tab, foreground or background, that appears in the ("Shell.Application").Windows collection.
That just shows your lack of experience. The functions have 2 different approaches - on purpose. IEGet is a more simplistic way of looping through all the IE tabs/windows & finding a name. WBGet actually accesses the webbrowser object from any Internet Explorer_Server (ActiveX) control. Make no mistake, the approach of WBGet is more effective, but both approaches serve a purpose.
Concerning not being able to access a background tab, I propose this:
ie := ComObjCreate("InternetExplorer.Application")
ie.Navigate("www.autohotkey.com/board/index.php?app=core&module=search")
ie.Navigate("www.google.com", 2048)
ie.Visible := true
while ie.busy
sleep 10
wb := WBGet("ahk_id" ie.hwnd, 2)
wb.document.getElementById("query").value := "Search Term"
Now you may ask - is there any way to loop through all the IE Tabs & utilize the approach of WBGet? Good question - yeah:
WinGet, windows, List, ahk_class IEFrame
Loop %windows% {
hwnd := windows%A_Index%
WinGet, controls, ControlList, ahk_id %hwnd%
StringReplace, controls, controls, Internet Explorer_Server, , UseErrorLevel
if ErrorLevel {
data .= hwnd "`n"
Loop %ErrorLevel%
data .= " Svr# " A_Index " - " WBGet("ahk_id" hwnd, A_Index).locationName "`n"
data .= "`n"
}
}
Msgbox %data%