This repository has been archived by the owner on Sep 19, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
update.ahk
82 lines (58 loc) · 1.64 KB
/
update.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
;============== CONFIG
global SCRNAME:="YDL Updater"
global EXE:="ydl.ahk"
global TEMP:=A_ScriptDir "\temp"
Options:=[ { "url": "https://codeload.github.com/pukkandan/youtube-dl/zip/my-tweaks", unzip:True }
,{ "url": "https://codeload.github.com/pukkandan/YDL/zip/master"
,"temp": True, unzip:True
,"run": "YDL-master\update-run-once.ahk" } ]
;=================== CODE
FileInstall, icon.png, icon.png
SetWorkingDir, % A_ScriptDir
#SingleInstance, force
#NoEnv
if FileExist("icon.png")
Menu, Tray, Icon, icon.png
Menu, Tray, Tip, % SCRNAME
;#NoTrayIcon
FileCreateDir, % TEMP
zipfile:=TEMP "\update.zip"
for _,item in Options {
URLDownloadToFile, % item.url, % zipfile
if ErrorLevel {
showErr("Downloading", item.url)
return
}
;msgbox % "downloaded " item.url
path:= item.temp? TEMP : A_WorkingDir
if item.unzip
unzip(zipfile, path)
;msgbox % "unzipped " zipfile
FileDelete, % zipfile
if item.hasKey("run") {
sleep 100
run, % path "\" item.run,, UseErrorLevel
}
}
sleep 100
run, % EXE
showErr(action, val) {
msgbox, 16, % SCRNAME, Error in %action% "%val%"
return false
}
;================= LIB
; https://github.com/shajul/Autohotkey/blob/master/COM/Zip Unzip Natively.ahk
unzip(zipFullPath, folderFullPath) {
folderFullPath:=RegExReplace(folderFullPath, "\\$")
FileCreateDir, % folderFullPath
SA:=ComObjCreate("Shell.Application")
pzip:=SA.Namespace(zipFullPath)
pfol:=SA.Namespace(folderFullPath)
zippedItems:=pzip.items().count
pfol.CopyHere(pzip.items(), 4|16 )
while (pfol.items().count<zippedItems) { ; Wait for completion
;tooltip, pfol.items().count
sleep 100
}
return zippedItems
}