I trying to create function which will help to handle loading page delays, but for some reason this function does nothing.
Could someone help me with this function why it is not working? Or maybe someone uses something similar?
I planing to do - While element is not visible on page start timing for 1 min, if after one min will not appear that element, close function.
Code: Select all
#SingleInstance, Force
^y::
; www.yahoo.com ; searching for id element Header
pwb := WBGet()
waitForIdElement("Header") ; call function,
waitForIdElement(htmlIdElement)
{
while(!Element := pwb.document.getElementByID(%htmlIdElement%)) ; Make sure element exist before moving forward
Sleep, 50
MsgBox, what kind part it is?
while(Element.offsetWidth=0) AND (Element.offsetHeight=0) ; if height = 0 and width = 0 then not visible
Sleep, 50
MsgBox, this is second msg box
}
return
; connection to IE
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)
}
}
}
^+x::ExitApp