-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathautoUpdate.ahk
35 lines (32 loc) · 1.3 KB
/
autoUpdate.ahk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
autoUpdate(path:="", download:=True, install:=False, openCLog:=True){
regexMatch(Download("https://autohotkey.com/download/1.1/version.txt"),"^\d+\.\d+\.\d+(\.\d+)?$",v)
if !v
return -1
else if (v<=A_AhkVersion){
if FileExist("ahk.exe") { ;Last run was an update
if path
FileMove, ahk.exe, %path%\AutoHotkey_%v%_setup.exe, 0 ;Dont replace
FileDelete, ahk.exe ;If exe still exists
Toast.show({title:{text:"AHK Updated"}, life:openHelp?500:0})
if openCLog
ShellRun(PRG_RS_CHM.process, "mk:@MSITStore:" SCR_AHKDir "\AutoHotkey.chm::/docs/AHKL_ChangeLog.htm")
return 2
}
else return 0
}
Toast.show({title:{text:"AHK v" v " Available"}, life:download?500:0})
if (download) {
while !fileExist("ahk.exe")
Download_toFile("https://github.com/Lexikos/AutoHotkey_L/releases/latest/download/AutoHotkey_" v "_setup.exe", "ahk.exe")
Toast.show({title:{text:"AHK v" v " Downloaded"}, life:install?500:0})
if (install) {
run *RunAs ahk.exe /s /r /IsHostApp
} else {
msgbox, 0x4, AHK v%v%, Update AHK?
IfMsgBox Yes
run *RunAs ahk.exe /s /r /IsHostApp
}
}
return 1
}
;autoUpdate() ; Test