#NoEnv
#Persistent
SetBatchLines -1
SetWorkingDir %A_ScriptDir%
; https://www.autohotkey.com/boards/viewtopic.php?f=76&t=87079

url := "https://www.autohotkey.com/download/ahk-install.exe"
localPath := A_ScriptDir . "\ahk-install.exe"

; 下载多个文件,将下载代码和回调函数改名复制一份即可
Req := ComObjCreate("Msxml2.XMLHTTP.6.0")
Req.Open("GET", url, true)
Req.onreadystatechange := Func("Ready").Bind(Req, localPath)
Req.Send()

Loop {
  ToolTip % "不阻塞主线程计时:" A_Index
  Sleep 1000
}
Return

Ready(Req, filePath) {
  if !(Req.readyState = 4 && Req.status = 200)
    Return

  Arr := Req.responseBody
  pData := NumGet(ComObjValue(Arr) + 8 + A_PtrSize)
  len := Arr.MaxIndex() + 1
  FileOpen(filePath, "w").RawWrite(pData + 0, len)
  MsgBox, File downloaded
}

 

声明:站内资源为整理优化好的代码上传分享与学习研究,如果是开源代码基本都会标明出处,方便大家扩展学习路径。请不要恶意搬运,破坏站长辛苦整理维护的劳动成果。本站为爱好者分享站点,所有内容不作为商业行为。如若本站上传内容侵犯了原著者的合法权益,请联系我们进行删除下架。