[Script] A simple github update checker

Post your working scripts, libraries and tools for AHK v1.1 and older
ananthuthilakan
Posts: 188
Joined: 08 Jul 2019, 05:37
Contact:

[Script] A simple github update checker

Post by ananthuthilakan » 01 Apr 2023, 07:30

A simple github update checker ahk l v1

A multithreaded version can be found here ( require ahk_h ) viewtopic.php?f=65&t=115633

Code: Select all

/*
A simple github update checker ahk l v1

Author : ananthuthilakan 
dischord : discretecourage#0179
Website : ananthuthilakan.com
github : https://github.com/ananthuthilakan/Github_Update_Checker

Credits :  ahktojson by teadrinker 
*/


#NoEnv
#SingleInstance, Force
SendMode, Input
SetBatchLines, -1
SetWorkingDir, %A_ScriptDir%


;=============== CURRENT VERSION ==================================

Current_version:="v1.0.0.0"  ; In github always create new release tag in this pattern

;==================================================================

repoOwner := "ananthuthilakan"                  ; Change to your repository Owner Name
repoName := "Github_Update_Checker"             ; Your Repository Name

try
{
url := "https://api.github.com/repos/" repoOwner "/" repoName "/releases/latest"
WinHttpReq := ComObjCreate("WinHttp.WinHttpRequest.5.1")
WinHttpReq.Open("GET", url)
WinHttpReq.Send()
data:=JsonToAHK(WinHttpReq.ResponseText)
latest_version := StrSplit(data["html_url"],"/")[8]
}



if (Current_version!=latest_version) && (latest_version)
    {
MsgBox 0x40044, New Update Available, Your current version   : %Current_version% `nNew version available   : %latest_version%`n`nDo you want to update ?

IfMsgBox Yes, {
    Try 
    Run,% "https://github.com/" repoOwner "/" repoName "/releases/latest"  
    ; "https://github.com/" repoOwner "/" repoName "/releases/latest/download/your_file_to_download" ; directdownloadlink use UrlDownloadToFile

} Else IfMsgBox No, {

}
    }
return








JsonToAHK(json, rec := false) {
    static doc := ComObjCreate("htmlfile")
          , __ := doc.write("<meta http-equiv=""X-UA-Compatible"" content=""IE=9"">")
          , JS := doc.parentWindow
    if !rec
       obj := %A_ThisFunc%(JS.eval("(" . json . ")"), true)
    else if !IsObject(json)
       obj := json
    else if JS.Object.prototype.toString.call(json) == "[object Array]" {
       obj := []
       Loop % json.length
          obj.Push( %A_ThisFunc%(json[A_Index - 1], true) )
    }
    else {
       obj := {}
       keys := JS.Object.keys(json)
       Loop % keys.length {
          k := keys[A_Index - 1]
          obj[k] := %A_ThisFunc%(json[k], true)
       }
    }
    Return obj
 }

sashaatx
Posts: 333
Joined: 27 May 2021, 08:27
Contact:

Re: [Script] A simple github update checker

Post by sashaatx » 25 Jun 2023, 01:25

https://github.com/samfisherirl
? /Easy-Auto-GUI-for-AHK-v2 ? /Useful-AHK-v2-Libraries-and-Classes : /Pulovers-Macro-Creator-for-AHKv2 :

Post Reply

Return to “Scripts and Functions (v1)”