This repository was archived by the owner on Feb 4, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUpdater.au3
195 lines (155 loc) · 5 KB
/
Updater.au3
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
#NoTrayIcon
#RequireAdmin
#AutoIt3Wrapper_AU3Check_Parameters=-q -d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7
;---------------------------------------------------------------------------
;
#AutoIt3Wrapper_Outfile_type=a3x
#AutoIt3Wrapper_Run_Au3Stripper=y
#Au3Stripper_Parameters=/pe /sf=1 /sv=1 /rm /rsln
;
;---------------------------------------------------------------------------
;---------------------------------------------------------------------------
;
AutoItSetOption('GUICloseOnESC', 0)
AutoItSetOption('GUIOnEventMode', 1)
AutoItSetOption('MustDeclareVars', 1)
;
;---------------------------------------------------------------------------
;---------------------------------------------------------------------------
;
#include <ButtonConstants.au3>
#include <FontConstants.au3>
#include <GUIConstantsEx.au3>
#include <InetConstants.au3>
#include <MsgBoxConstants.au3>
#include <ProgressConstants.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
;
;---------------------------------------------------------------------------
;---------------------------------------------------------------------------
;
Global $sUrl = ''
Global $sFileName = ''
Global $btnCancel = 0
Global $hInet = 0
Global $bInterrupt = False
If $CmdLine[0] Then
$sUrl = $CmdLine[1]
$sFileName = StringSplit($sUrl, '/')[5]
Else
Exit
EndIf
;
;---------------------------------------------------------------------------
Form()
While True
Sleep(1000)
If $bInterrupt Then
Form()
InetClose($hInet)
FileDelete($sFileName)
Exit
EndIf
If InetGetInfo($hInet, $INET_DOWNLOADCOMPLETE) Then
Form()
If InetGetInfo($hInet, $INET_DOWNLOADSUCCESS) Then
InetClose($hInet)
Clean()
Install()
Else
InetClose($hInet)
FileDelete($sFileName)
MsgBox(BitOR($MB_OK, $MB_ICONERROR), 'AFK Manager', 'Unable to update to the latest version.')
EndIf
Exit
EndIf
WEnd
Func Form()
;---------------------------------------------------------------------------
;
Local Static $hWnd = 0
If $hWnd Then
GUIRegisterMsg($WM_COMMAND, '')
GUIDelete($hWnd)
$hWnd = 0
Return
EndIf
;
;---------------------------------------------------------------------------
;---------------------------------------------------------------------------
;
Local $WIDTH = 350
Local $HEIGHT = 190
Local $LEFT = 1
Local $TOP = 21
$hWnd = GUICreate('AFK Manager', $WIDTH + 2, $HEIGHT + 22, -1, -1, $WS_POPUP)
GUISetBkColor(0xEFEFF2, $hWnd)
GUISetFont(8.5, $FW_NORMAL, Default, 'Tahoma', $hWnd, $DEFAULT_QUALITY)
GUICtrlCreateLabel('', 0, 0, $WIDTH + 2, 21)
GUICtrlSetBkColor(-1, 0x007ACC)
GUICtrlSetState(-1, $GUI_DISABLE)
GUICtrlCreateLabel('', $WIDTH + 1, 21, 1, $HEIGHT)
GUICtrlSetBkColor(-1, 0x007ACC)
GUICtrlCreateLabel('', 0, $HEIGHT + 21, $WIDTH + 2, 1)
GUICtrlSetBkColor(-1, 0x007ACC)
GUICtrlCreateLabel('', 0, 21, 1, $HEIGHT)
GUICtrlSetBkColor(-1, 0x007ACC)
GUICtrlCreateLabel('AFK Manager', 6, 3, $WIDTH - 10, 15, $SS_CENTERIMAGE, $GUI_WS_EX_PARENTDRAG)
GUICtrlSetBkColor(-1, 0x007ACC)
GUICtrlSetColor(-1, 0xFFFFFF)
;
;---------------------------------------------------------------------------
;---------------------------------------------------------------------------
;
GUICtrlCreateLabel('Updating AFK Manager, please wait...', $LEFT + 50, $TOP + 50, -1, 15)
GUICtrlCreateProgress($LEFT + 50, $TOP + 70, 250, 25, $PBS_MARQUEE)
GUICtrlSendMsg(-1, $PBM_SETMARQUEE, True, 50)
$btnCancel = GUICtrlCreateButton('Cancel', $LEFT + 125, $TOP + 115, 100, 25)
;
;---------------------------------------------------------------------------
;---------------------------------------------------------------------------
;
$hInet = InetGet($sUrl, $sFileName, BitOR($INET_FORCERELOAD, $INET_IGNORESSL, $INET_FORCEBYPASS), $INET_DOWNLOADBACKGROUND)
GUIRegisterMsg($WM_COMMAND, WM_COMMAND)
GUISetState(@SW_SHOW, $hWnd)
;
;---------------------------------------------------------------------------
EndFunc
Func Clean()
ProcessClose('AFK Manager.exe')
Local $avGarenaRoom = ProcessList('garena_room.exe')
If @error Then
; --- Nothing to do
Else
For $i = 1 To $avGarenaRoom[0][0]
ProcessClose($avGarenaRoom[$i][1])
Next
EndIf
Local $avGarenaMessenger = ProcessList('GarenaMessenger.exe')
If @error Then
; --- Nothing to do
Else
For $i = 1 To $avGarenaMessenger[0][0]
ProcessClose($avGarenaMessenger[$i][1])
Next
EndIf
EndFunc
Func Install()
Local $iProcessId = 0, $hWnd = 0
$iProcessId = Run($sFileName)
$hWnd = WinWait('AFK Manager Setup', 'Welcome to AFK Manager Setup')
ControlClick($hWnd, '', 'Button2')
$hWnd = WinWait('AFK Manager Setup ', 'Choose the folder in which to install AFK Manager.')
ControlClick($hWnd, '', 'Button2')
$hWnd = WinWait('AFK Manager Setup ', 'AFK Manager has been installed on your computer.')
ControlClick($hWnd, '', 'Button2')
ProcessWaitClose($iProcessId)
FileDelete($sFileName)
EndFunc
Func WM_COMMAND($hWnd, $uMsg, $wParam, $lParam)
#forceref $hWnd, $uMsg, $lParam
If BitAND($wParam, 0xFFFF) = $btnCancel And BitShift($wParam, 16) = $BN_CLICKED Then
$bInterrupt = True
EndIf
EndFunc