Skip to content

Instantly share code, notes, and snippets.

@JoeGlines
Created June 20, 2023 19:16
Show Gist options
  • Save JoeGlines/79d4beeeb6a4f3401b173cfd2e8b8669 to your computer and use it in GitHub Desktop.
Save JoeGlines/79d4beeeb6a4f3401b173cfd2e8b8669 to your computer and use it in GitHub Desktop.
;***********This will write a binary file to the folder where script is running*******************
;***********Another great reason to use MSXML2 is that it will use your IE cookies so you don't have to deal with Authentication :)*******************
;***********Also read this post for pros/cons of each method: https://autohotkey.com/boards/viewtopic.php?t=9554*******************
URL:="http://the-automator.com/mn/wp-content/uploads/2016/02/not_working.jpg"
SplitPath,URL,File_Name
HTTP:=ComObjCreate("MSXML2.XMLHTTP.6.0") ;https://msdn.microsoft.com/en-us/library/ms535874(v=vs.85).aspxu
ADODB:=ComObjCreate("ADODB.Stream") ;https://docs.microsoft.com/en-us/sql/ado/reference/ado-glossary
ADODB.Type:=1 ;set to 1 which is Binary 2 is text
HTTP.Open("GET",URL,1) ;open( Method, URL, Asynchronous, UserName, Password )
HTTP.Send()
while(HTTP.ReadyState!=4) ;Wait for it to complete
Sleep,50
ADODB.Open() ;After it HTTP API call completes,
ADODB.Write(HTTP.ResponseBody) ;Write the binary data into ADODB Stream
ADODB.SaveToFile(A_WorkingDir "\" File_Name,2) ;Save it to a file
ADODB.Close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment