...........
If this is all your code, you aren't using Sean's method correctly. Please post all your code (or at least all your code that is relevant - ie. How is your While-loop breaking?).
no, obviuosly not. sorry my mistake, here is the complete thing.
#Persistent
sUrl := "http://127.0.0.1:81/Upload.html"
COM_Init()
pweb := COM_CreateObject("InternetExplorer.Application")
sink := COM_ConnectObject(pweb, "IE_")
bComplete := False
COM_Invoke(pweb, "Navigate", sUrl)
While !bComplete
Sleep, 500
MsgBox, 36, , Do you want it visible?
IfMsgBox, Yes
COM_Invoke(pweb, "Visible", True)
;MsgBox % COM_Invoke(pwb, "document.getElementsByTagName[h1][0].innerHTML")
;MsgBox % COM_Invoke(pwb,"document.all.tags[h1].item[0].innerHTML")
MsgBox % COM_Invoke(pwb,"document.getElementsByTagName[h1].item[0].innerHTML")
MsgBox, 36, , Do you want to close it?
IfMsgBox, Yes
[color=red]COM_Invoke(pweb, "Quit")[/color]
COM_DisconnectObject(sink)
COM_Release(pweb)
COM_Term()
#q::ExitApp ;WIN key + q to terminate this script
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
}
that line in red is actually quitting the browser session so I guess the pwb object is open and responding correctly... not when I try to access the
document though. and as you can see by the commented lines not even tank's suggestions work (btw I love that pissed off Yoda. just great)
the code on top (autoexec section) is of course just a bunch of lines to test functionalities so to manipulate IE (the finished code shouldn't even make IE object visible).
I've tried these and they work wonders (of-bloody-course):
;js_Snippet = javascript`:document`.getElementsByTagName`(`"h1`"`)`[0`]`.innerHTML`;
js_Snippet = javascript`:alert`(document`.getElementsByTagName`(`"h1`"`)`[0`]`.innerHTML`)`;
COM_Invoke(pweb, "Navigate", js_Snippet)
which I seem to understand means that, since
pweb (the IE object) works fine, I need another handle to reference the document object to start using its exposed functions (properties and methods).
Am I getting it right?...