This is the 7th video in my series of automating logging into websites with AutoHotkey. In this tutorial I show how to login to Reddit.
In this video we had a small hiccup where I used the classname and had assumed it was unique. Turns out the there was another button on the page with the exact same classnames! It was not a big issue, but definitely a good example of how you need to troubleshoot/test your code!
Below is the video showing how I automated the login to Reddit with AutoHotkey
AutoHotkey Script to Login to Reddit
#SingleInstance, Force
Browser_Forward::Reload ;RControl::
Browser_Back::
pwb := WBGet()
If (pwb.locationURL!="https://www.reddit.com/login"){
pwb.Navigate("https://www.reddit.com/login") ;Navigate to URL
while pwb.busy or pwb.ReadyState != 4 ;Wait for page to load
Sleep, 100
}
pwb.document.all.user_login.Value :="joetazz" ;Unique ID -no dashes
pwb.document.all.passwd_login.Value :="The_Stupidist_Password!" ;Unique ID -no dashes
pwb.document.all.rem_login.checked :=1 ;Set Tagname and Array value
pwb.document.getElementsByClassName("c-btn c-btn-primary c-pull-right")[1].click()
;************Pointer to Open IE Window******************
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)
}
}
}


