this script
Code:
; Run, iexplore.exe http://www.google.com/
MsgBox, % IEReady()
Return
IEReady(hIESvr = 0)
{
If Not hIESvr
{
Loop, 50
{
ControlGet, hIESvr, hWnd, , Internet Explorer_Server1, A ; ahk_class IEFrame
If hIESvr
Break
Else Sleep 100
}
If Not hIESvr
Return """Internet Explorer_Server"" Not Found."
}
Else
{
WinGetClass, sClass, ahk_id %hIESvr%
If Not sClass == "Internet Explorer_Server"
Return "The specified control is not ""Internet Explorer_Server""."
}
COM_Init()
If DllCall("SendMessageTimeout", "Uint", hIESvr, "Uint", DllCall("RegisterWindowMessage", "str", "WM_HTML_GETOBJECT"), "Uint", 0, "Uint", 0, "Uint", 2, "Uint", 1000, "UintP", lResult)
&& DllCall("oleacc\ObjectFromLresult", "Uint", lResult, "Uint", COM_GUID4String(IID_IHTMLDocument2,"{332C4425-26CB-11D0-B483-00C04FD90119}"), "int", 0, "UintP", pdoc)=0
&& pdoc && pweb:=COM_QueryService(pdoc,IID_IWebBrowserApp:="{0002DF05-0000-0000-C000-000000000046}")
Loop
If COM_Invoke(pweb, "ReadyState") = 4
Break
Else Sleep 500
COM_Release(pdoc)
COM_Release(pweb)
COM_Term()
Return pweb ? "DONE!" : False
}
Brillantly written by Sean does require the page to be the active window as well as the page to be the active tab (For IE7)
However to use the topmost instance of IE but not necesarily an active instance change
Code:
ControlGet, hIESvr, hWnd, , Internet Explorer_Server1, A ; ahk_class IEFrame
to
Code:
ControlGet, hIESvr, hWnd, , Internet Explorer_Server1, ahk_class IEFrame
a way to do this same thing without regard to active window would be like this ill use the page title instead here. The title need not remain the same but will at the initial call of the script need to match even if the page is not in an active tab (For IE7)
Code:
MsgBox, % alt_IEReady("Google") ;; substitute any page title without the windows/internet explorer suffix
Return
alt_IEReady(pageSearched)
{
Loop, % COM_Invoke(psw := COM_Invoke(psh:=COM_CreateObject("Shell.Application"), "Windows"), "Count")
{
LocationName:=COM_Invoke(pwb:=COM_Invoke(psw, "Item", A_Index-1), "LocationName")
IfInString,LocationName,%pageSearched%
Break
COM_Release(pwb) ;didnt break so release the one we didnt use
}
loop
If (rdy:=COM_Invoke(pwb,"readyState") = 4)
break
COM_Release(psw), VarSetCapacity(psw, 0)
COM_Release(psh), VarSetCapacity(psh, 0)
COM_Release(pwb), VarSetCapacity(pwb, 0)
}