Skip to content

Instantly share code, notes, and snippets.

@JoeGlines
Last active April 26, 2021 15:51
Show Gist options
  • Save JoeGlines/af7698ee9049e4417746c36329bd9921 to your computer and use it in GitHub Desktop.
Save JoeGlines/af7698ee9049e4417746c36329bd9921 to your computer and use it in GitHub Desktop.
Example using the xmlHTTPrequest from the IE page
;*******************************************************
; Want a clear path for learning AutoHotkey; Take a look at our AutoHotkey Udemy courses. They're structured in a way to make learning AHK EASY
; Right now you can get a coupon code here: https://the-Automator.com/Learn
;*******************************************************
;********************Run the XMLRequest from the IE page (thanks Jackie Sztuk!)***********************************
;~ An Ajax ("Asynchronous Javascript and XML") request is sometimes called an XHR request
oWindow:=ComObject(9,ComObjQuery(WBGet(),"{332C4427-26CB-11D0-B483-00C04FD90119}","{332C4427-26CB-11D0-B483-00C04FD90119}"),1)
xhr := oWindow.XMLHttpRequest()
xhr.Open("GET","https://www.autohotkey.com/boards/memberlist.php?mode=viewprofile&u=114",1)
xhr.send()
while(xhr.ReadyState!=4) ;Wait for it to complete
Sleep,50
DisplayHTML(XHR.ResponseText,1400,1000)
DisplayHTML(HTML,w=300,h=400){
static wb
gui,margin,0,0
gui, Add, ActiveX, x0 y0 w%w% h%h% vWB, shell explorer
wb.Silent:=True
wb.Navigate("about:blank")
wb.document.write(HTML)
gui, Show, , HTML returned
}
;~ http://www.autohotkey.com/board/topic/47052-basic-webpage-controls-with-javascript-com-tutorial/
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
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)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment