Skip to content

Instantly share code, notes, and snippets.

Created April 26, 2012 17:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/2501110 to your computer and use it in GitHub Desktop.
Save anonymous/2501110 to your computer and use it in GitHub Desktop.
Run www.google.com
WinWaitActive, Google
IEReady()
Msgbox Page Loaded
IEReady(hIESvr = 0)
{
static IID_IWebBrowserApp := "{0002DF05-0000-0000-C000-000000000046}"
, IID_IHTMLWindow2 := "{332C4427-26CB-11D0-B483-00C04FD90119}"
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""."
}
If Acc := Acc_ObjectFromWindow(hIESvr)
If pWin := ComObjQuery(Acc, IID_IHTMLWindow2, IID_IHTMLWindow2)
If pwb := ComObjQuery(pWin, IID_IWebBrowserApp, IID_IWebBrowserApp) {
wb := ComObj(9,pwb,1)
While, wb.ReadyState <> 4
Sleep, 500
While, wb.document.readyState <> "complete"
Sleep, 500
}
ObjRelease(pWin)
Return pwb ? "DONE!" : False
}
Acc_ObjectFromWindow(hWnd, idObject = -4) ; from the Acc Library
{
; Acc_Init()
static h
If Not h
h:=DllCall("LoadLibrary","Str","oleacc","Ptr")
If DllCall("oleacc\AccessibleObjectFromWindow", "Ptr", hWnd, "UInt", idObject&=0xFFFFFFFF, "Ptr", -VarSetCapacity(IID,16)+NumPut(idObject==0xFFFFFFF0?0x46000000000000C0:0x719B3800AA000C81,NumPut(idObject==0xFFFFFFF0?0x0000000000020400:0x11CF3C3D618736E0,IID,"Int64"),"Int64"), "Ptr*", pacc)=0
Return ComObjEnwrap(9,pacc,1)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment