commit d882f438547288640d4f6663d064771a2838a424 Author: yuriy Date: Sat Aug 26 00:20:09 2023 -0400 first commit diff --git a/Gitea-API.ahk b/Gitea-API.ahk new file mode 100644 index 0000000..b34d6a1 --- /dev/null +++ b/Gitea-API.ahk @@ -0,0 +1,80 @@ +; GITEA Functions +;------------------------------------------------ +CheckForUpdates(GitReleasesAPIURL){ + ; msgbox, checking for updates + Message = Checking For Updates + SaveOrPostProgress(Message,PostType:="ErrorLoggingTextFile") + + data := URLDownloadToVar(GitReleasesAPIURL) + ; Msgbox % "data: " data + + parsed := JSON.Load(data) + + UpdateVersionNumber := parsed.1.name + + ; Message = UpdateVersionNumber: %UpdateVersionNumber% + ; DevModeMsgBox(Message) + + + if(ScriptVersion = UpdateVersionNumber OR ScriptVersion > UpdateVersionNumber){ + ToolTip + return 0 + } + else, { + UpdateAvailable := 1 + ; msgbox, update found! + Message = Program Update Found + SaveOrPostProgress(Message:=Message,PostType:="ErrorLoggingTextFile") + ; IniWrite, 1, %SettingsIniFilepath%, %ScriptSettingsSection%, UpdateAvailable + ; ToolTip + return 1 +} + +} + + +UpdateScript(){ + data := URLDownloadToVar(GitReleasesAPIURL) + + parsed := JSON.Load(data) + + UpdateVersionNumber := parsed.1.name + ChangeLog := parsed.1.body + exename := parsed.1.assets.1.name + exeURL := parsed.1.assets.1.browser_download_url + + ; Msgbox % "UpdateVersionNumber: " UpdateVersionNumber + ; msgbox, Version: %Version% + ; Msgbox % "ChangeLog: " ChangeLog + ; Msgbox % "exeURL: " exeURL + ; Msgbox % "exename: " exename + + ExeName := StrReplace(exename, ".exe", "") + UpdateExeName = %exename% %UpdateVersionNumber%.exe + UpdateExeFilepath = %A_ScriptDir%\%UpdateExeName% + + if(ScriptVersion = UpdateVersionNumber){ + ; IniWrite, 0, %SettingsIniFilepath%, %ScriptSettingsSection%, UpdateAvailable + MsgBox, You are Up-To-Date + ; IniRead, UpdateAvailable, %SettingsIniFilepath%, %ScriptSettingsSection%, UpdateAvailable, 0 + return + } + + Changelog = %ScriptVersion% --> %UpdateVersionNumber%`n%Changelog% + + OnMessage(0x44, "OnMsgBoxUpdateAvailable") + MsgBox 0x44, Update Available, %Changelog% + OnMessage(0x44, "") + + IfMsgBox Yes, { + Return + } + Else IfMsgBox No, { + SaveOrPostProgress(Message:="Downloading Update",PostType:="Tooltip,ErrorLoggingTextFile") + ; Msgbox, downloading to: %A_ScriptDir%\%UpdateExeName% + UrlDownloadToFile, %exeURL%, %UpdateExeFilepath% + run, "%UpdateExeFilepath%" "%A_ScriptFullPath%" + ExitApp + } + return +}