Quote:
yeah so, this is apparently all over my head.
Quote:
This is the first time I've worked with AHK, and i'm pretty lost.
That's quite alright.

According to the Wiki, these are Advanced topoics -
http://www.autohotkey.com/wiki/index.ph ... =Tutorials
You may want to check out "COM Tutorial by tank" & "Control/manipulate webpages using JavaScript by daonlyfreez"
Note - Tank's tutorial was written before the "Dot Syntax" was incorporated into the COM.ahk Library. Example:
Code:
COM_Invoke(pwd, "document.getElementById[Passwd]")
;would have been written:
COM_Invoke(COM_Invoke(pwd, "document"), "getElementById", "Passwd")
What version of IE are you working with? The IEReady() function usually works fine for me on IE 6, but it's not working well for me on IE 8. Perhaps try removing the
IEReady() function for now, and use
Sleep 5000 (or however long it takes for the page to refresh usually)
Example script:Load
www.Google.com. Run this code (Hotkey: ^d). This will keep refreshing every 3 seconds because the element doesn't exist.
Then pause the script, and click on the Gmail link on the top of the webpage. After this is loaded, unpause the script. The DONE! msgbox should display because now the element exists.
Code:
GetWebBrowser() ; written by Sean
{
ControlGet, hIESvr, hWnd, , Internet Explorer_Server1, ahk_class IEFrame
If Not hIESvr
Return
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)
IID_IWebBrowserApp := "{0002DF05-0000-0000-C000-000000000046}"
pweb := COM_QueryService(pdoc,IID_IWebBrowserApp,IID_IWebBrowserApp)
COM_Release(pdoc)
Return pweb
}
^d::
COM_Init()
pwd := GetWebBrowser()
loop
{ COM_Invoke(pwd, "Navigate", "javascript:location.reload(true)")
sleep 3000
if % COM_Invoke(pwd, "document.getElementById[Passwd]")
break
}
msgbox DONE!
return
EDIT 
Try completely loading the page you're working with, and run this script:
Code:
^d::
COM_Init()
pwd := GetWebBrowser()
msgbox % COM_Invoke(pwd, "ReadyState")
return
That is the value of "ReadyState" when the page is fully loaded. If this value is not
4, you may be able to alter the IEReady() function to fix the waiting until fully loaded problem:
Code:
IEReady(hIESvr = 0) ; written by Sean
{
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 ; <-- Change 4 to different value
Sleep, 500
While, COM_Invoke(pweb, "document.readyState") <> "complete"
Sleep, 500
COM_Release(pweb)
}
COM_Release(pdoc)
COM_Term()
Return pweb ? "DONE!" : False
}