Code: Select all
UrlDownloadToFile, http://autohotkey.com/download/1.1/version.txt, AutoHotkey.txt
Is there some other bit of code that a script needs to be able to use UrlDownloadToFile?
Code: Select all
UrlDownloadToFile, http://autohotkey.com/download/1.1/version.txt, AutoHotkey.txt
Like NightWolf85 said the script works as expected.CodeRooney wrote:Nothing happens
Code: Select all
UrlDownloadToFile, http://autohotkey.com/download/1.1/version.txt, %A_Desktop%/AutoHotkey.txt
Code: Select all
;- 3 examples
;- if no succes with urldownloadtofile
setworkingdir,%a_scriptdir%
A =%A_AHKVERSION%
ur1:="https://autohotkey.com/download/1.1/version.txt"
SplitPath,ur1, name1, dir1, ext, name_no_ext, drive
gosub,case1 ;- variable
gosub,case2 ;- urldownloadtofile
gosub,case3 ;- wget
return
;-----------------------------------------------
CASE1:
;- CASE-1 Write to variable --------------------
hh:=ComObjCreate("WinHttp.WinHttpRequest.5.1")
ComObjError(false) ;- doesn't show error
hh.Silent := True ;- script failure = off
hh.SetTimeouts(500,500,500,500)
try {
hh.Open("GET",ur1,true) ;Open communication
hh.Send() ;Send the "get" request
hh.WaitForResponse()
aac=
aac:=hh.ResponseText ;Set the "aac" variable to the response
} catch error {
xxx:=error.Message
msgbox, 262208,ERROR ,Error=Catch`n%ur1%`nVariable AAC is empty`n------------------------------------------`n%xxx%`n------------------------------------------,
}
if aac<>
{
msgbox, 262208,AAC ,CASE1=`n%aac%
return
}
else
{
msgbox, 262208, ,No success`nTry now with UrlDownLoadToFile CASE-2
return
}
return
;====================================================
CASE2:
;- CASE-2 UrlDownLoadToFile --------------------
f2=%a_scriptdir%\CASE2_%name1%
urldownloadtofile,%ur1%,%f2%
ifexist,%f2%
msgbox, 262208,UrlDownLoadToFile ,CASE-2`nSee File=%f2%
return
;====================================================
CASE3:
;- CASE-3 Try with WGET ----------------------
F3 =%a_scriptdir%\%name1%
ifnotexist,%F3%
{
wget1=%a_scriptdir%\wget.exe
ifnotexist,%wget1%
{
if A_Is64bitOS
x1=https://eternallybored.org/misc/wget/current/wget64.exe
else
x1=https://eternallybored.org/misc/wget/current/wget.exe
urldownloadtofile,%x1%,wget.exe
}
runwait,%comspec% /c wget --no-parent --referer=%dir1% "%ur1%",,hide
}
ifexist,%F3%
{
fileread,b,%F3%
msgbox, 262208,AHK-VERSION ,Latest AHK-VERSION=%b%`nYour AHK-VERSION=%a_ahkversion%
if (A<>B)
{
msgbox, 262436,AHK-Version ,(Changed)`nYour existing version is=%A%`n Actual version is=%B%`n64-bit=%a_is64bitos%`nUnicode=%a_isunicode%`nOS=%a_osversion%`nWant you open Autohotkey downloads page ?
IfMsgBox,No
return
Else
{
run,https://autohotkey.com/download/
;run,https://autohotkey.com/download/ahk-install.exe
return
}
}
else
{
msgbox, 262436,AHK-Version ,(Equal)`nYour existing version is=%A%`n Actual version is=%B%`n64-bit=%a_is64bitos%`nUnicode=%a_isunicode%`nOS=%a_osversion%`nWant you open Autohotkey downloads page ?
IfMsgBox,No
return
Else
run,https://autohotkey.com/download/
return
}
}
return
;====================== end script ==================================
Users browsing this forum: wilkster and 326 guests