I've recently realized that URLDownloadToFile uses the IE proxy setting. So I'm looking for an alternative and found WinHttp.WinHttpRequest may work.
It seems the ResponseBody property contains the fetched data and I need to write it to a file. The problem is that I cannot find the byte size of it.
http://msdn.microsoft.com/en-us/library/windows/desktop/aa384106%28v=vs.85%29.aspx has the information for the object but I don't find relevant properties for it.
Can somebody tell how?
strURL := "http://www.mozilla.org/media/img/sandstone/buttons/firefox-large.png"
strFilePath := A_ScriptDir "\dl.jpg"
pwhr := ComObjCreate("WinHttp.WinHttpRequest.5.1")
pwhr.Open("GET", strURL)
pwhr.Send()
if (psfa := pwhr.ResponseBody ) {
oFile := FileOpen(strFilePath, "w")
; msgbox % ComObjType(psfa) ; 8209
oFile.RawWrite(psfa, strLen(psfa)) ; not working
oFile.Close()
}