Sean demonstrated further up this page (page 3) how to get the WebBrowser object (pweb) of a running instance of Internet Explorer.
Just in case, this technique can be used with any DOM objects, not only with Window object, as far as I tested. So, if don't like to use ACC.ahk, may do it with the code in the first post of this thread by adding:
pweb := COM_QueryService(pdoc,IID_IWebBrowserApp,IID_IWebBrowserApp)
so it works with an explorer instance that gets opened by clicking on a link on a webpage by javascript or such.
I'm not sure of exactly what you have in mind. If what lexicos suggested is what you wanted, you may ignore the following.
Here is one example, which will always open a new window for the page you clicked in the first/original start-up IE window, and waits for it completely loaded and then pop up message box.
#Persistent
OnExit, CleanUp
COM_CoInitialize()
pweb := COM_CreateObject("InternetExplorer.Application")
COM_Invoke(pweb, "Visible=", "True")
COM_Invoke(pweb, "Navigate", "http://www.autohotkey.com/forum/")
ReadyState(pweb)
MsgBox, Ready
COM_ConnectObject(pweb, "Web_")
Return
CleanUp:
COM_Release(pweb)
COM_CoUninitialize()
ExitApp
Web_BeforeNavigate2(prms, this)
{
NumPut(-1, NumGet(NumGet(prms+0)+8), 0, "short") ; cancel the navigation
pweb := COM_CreateObject("InternetExplorer.Application")
COM_Invoke(pweb, "Visible=", "True")
COM_Invoke(pweb, "Navigate", COM_DispGetParam(prms, 1))
ReadyState(pweb)
COM_Release(pweb)
MsgBox, Ready
}
ReadyState(pweb)
{
Loop
If COM_Invoke(pweb, "ReadyState") <> 4
Sleep, 500
Else Break
}