Code is from https://www.autohotkey.com/docs/commands/URLDownloadToFile.htm
(it just downloads the current version number of ahk from https://autohotkey.com/download/1.1/version.txt)
Code: Select all
#Persistent
return
^1:: ;Ctrl+1
req := ComObjCreate("Msxml2.XMLHTTP")
; also try Msxml2.XMLHTTP.3.0 , Msxml2.XMLHTTP.6.0 , Msxml2.ServerXMLHTTP
; Msxml2.ServerXMLHTTP.3.0 , Msxml2.ServerXMLHTTP.6.0 , Microsoft.XMLHTTP
req.open("GET", "https://autohotkey.com/download/1.1/version.txt", true)
req.onreadystatechange := Func("Ready")
req.send()
return
Ready(){
global req
if (req.readyState != 4) ; Not done yet.
return
if (req.status == 200) ; OK.
MsgBox % "Latest AutoHotkey version: " req.responseText
else
MsgBox 16,, % "Status " req.status
req.abort()
req := ""
}
Press Ctrl+1 to download the file
Download complete, but now CPU usage is pegged at 0.02
It seems that some thread belonging to the COM object must still be alive and needs to be released or closed the right way?
I've tried disconnecting the ComObj from events with ComObjConnect() and releasing its interface pointer with ObjRelease() (after getting it with ComObjType() and ComObjQuery() ).