AHK Version

许多实用脚本和封装函数, 可以让您编写脚本更加便捷高效

Moderators: tmplinshi, arcticir

garry
Posts: 3758
Joined: 22 Dec 2013, 12:50

AHK Version

18 Apr 2014, 13:52

check ahk version
EDIT :
modified= 20170102
URL has changed and had problem with urldownloadtofile

Code: Select all

;- https://autohotkey.com/docs/commands/URLDownloadToFile.htm
;- had no succes with urldownloadtofile used wget

setworkingdir,%a_scriptdir%
A =%A_AHKVERSION%

ur1:="https://autohotkey.com/download/1.1/version.txt"
SplitPath,ur1, name1, dir1, ext, name_no_ext, drive
f1 =%a_scriptdir%\%name1%

;- 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 ,%aac%
  return
  }
else
 msgbox, 262208, ,Variable AAC is empty`nTry now with UrlDownLoadToFile
;-----------------------------------------------

;- CASE-2 UrlDownLoadToFile --------------------
if aac=
  urldownloadtofile,%ur1%,%f1%
;-----------------------------------------------

;- CASE-3  Try with WGET  ----------------------
ifnotexist,%f1%
{
msgbox, 262208, ,No success with urldownloadtofile`nFile=%f1% doesn't exist`nTry now with WGET
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,%f1%
  {
  fileread,b,%f1%
  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 ==================================

Return to “脚本函数”

Who is online

Users browsing this forum: No registered users and 10 guests