forked from camerb/AHKs
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathIEReady.ahk
73 lines (65 loc) · 2.11 KB
/
IEReady.ahk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
;IE_Ready by Sean
;http://www.autohotkey.com/forum/viewtopic.php?t=19256
;#Persistent
;sUrl := "http://www.autohotkey.com/forum/"
;COM_Init()
;pweb := COM_CreateObject("InternetExplorer.Application")
;sink := COM_ConnectObject(pweb, "IE_")
;COM_Invoke(pweb, "Visible", True)
;bComplete := False
;COM_Invoke(pweb, "Navigate2", sUrl)
;While !bComplete
;Sleep, 500
;COM_DisconnectObject(sink)
;COM_Release(pweb)
;COM_Term()
;Return
;OnComplete:
;bComplete := True
;Return
;IE_DocumentComplete(prms, sink)
;{
;If NumGet(NumGet(prms+0)+24) = NumGet(sink+12)
;SetTimer, OnComplete, -10
;/* more rigorous way
;COM_Release(punk1:=COM_QueryInterface(NumGet(NumGet(prms+0)+24),0))
;COM_Release(punk2:=COM_QueryInterface(NumGet(sink+12),0))
;If (punk1 = punk2)
;SetTimer, OnComplete, -10
;*/
;}
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}")
{
While, COM_Invoke(pweb, "ReadyState") <> 4
Sleep, 500
While, COM_Invoke(pweb, "document.readyState") <> "complete"
Sleep, 500
COM_Release(pweb)
}
COM_Release(pdoc)
COM_Term()
Return pweb ? "DONE!" : False
}