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
}