In the sixth post of this series I demonstrate how to Login to Twitter with AutoHotkey.
In this web scraping example we saw how the Google login looks like it is loading a separate page but, in reality, is not. Web scraping is always fun (and can be very frustrating) because HTML developers can think of so many different ways to accomplish their objectives. Check this page for the other scripts I used in the video.
Video demonstrating Login to Twitter
AutoHotkey Script I wrote to Login to Twitter with AutoHotkey
#SingleInstance, Force Browser_Forward::Reload ;RControl:: Browser_Back:: ;************************************************************ pwb := WBGet() If (pwb.locationURL !="https://twitter.com/"){ pwb.Navigate("https://twitter.com/") ;Navigate to URL while pwb.busy or pwb.ReadyState != 4 ;Wait for page to load Sleep, 100 } pwb.document.GetElementsByName("session[username_or_email]")[0].Value :="Cathy@the-Automator.com" pwb.document.GetElementsByName("session[password]")[0].Value :="The_Stupidist_Password!" pwb.document.GetElementsByName("remember_me")[0].checked :=1 ;Set Tagname and Array value pwb.document.getElementsByClassName("submit btn primary-btn js-submit")[0].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) } } }