;=========================================================================================================== Includes #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include ;=========================================================================================================== Settings #AutoIt3Wrapper_icon=(@ScriptDir & "\ai.logo.ico") AutoItSetOption("GUICloseOnESC", 0) AutoItSetOption("TrayAutoPause", 0) AutoItSetOption("TrayIconHide", 1) AutoItSetOption("TrayMenuMode", 1) AutoItSetOption("WinDetectHiddenText", 1) AutoItSetOption("WinSearchChildren", 1) AutoItSetOption("WinTitleMatchMode", -2) GUISetIcon(@ScriptDir & "\ai.logo.ico", -1) HotKeySet("!{F4}", "_HawkingHole") ;=========================================================================================================== Variables Global $Countdown_Welcome = 10 Global $Total_Time_Welcome = $Countdown_Welcome Global $Form_Welcome = GUICreate("Application Installer - Welcome", 515, 401, -1, -1, $WS_POPUP) Global $Pic_Welcome = GUICtrlCreatePic(@ScriptDir & "\ai.welcome.jpg", 0, 0, 515, 401, $GUI_DISABLE) Global $Button1_Welcome = GUICtrlCreateButton("Update", 352, 363, 72, 22) Global $Button2_Welcome = GUICtrlCreateButton("Defer", 431, 363, 72, 22) Global $Progress_Welcome = GUICtrlCreateProgress(13, 364, 328, 20) Global $Hours_Welcome, $Mins_Welcome, $Secs_Welcome Global $Form_Update1 = GUICreate("Application Installer - Update1", 515, 401, -1, -1, $WS_POPUP) Global $Pic_Update1 = GUICtrlCreatePic(@ScriptDir & "\ai.update.jpg", 0, 0, 515, 401, $GUI_DISABLE) Global $pheight_Update1 = 129, $pwidth_Update1 = 129, $oIE_Update1, $GUIActiveX_Update1, $gif_Update1, $sizes_Update1 Global $Countdown_Defer = 30 Global $Total_Time_Defer = $Countdown_Defer Global $Form_Defer = GUICreate("Application Installer - Defer", 874, 40, -1, 30, $WS_POPUP + $WS_BORDER) Global $Button1_Defer = GUICtrlCreateButton("Update", 790, 5, 75, 30) Global $Progress_Defer = GUICtrlCreateProgress(8, 24, 770, 10) Global $LabelTxt1_Defer = "The Application Installer app update process has been deferred." Global $LabelTxt2_Defer = "Either wait for the progress indicator to fill or click the Update button to begin the update immediately..." Global $Label_Defer = GUICtrlCreateLabel($LabelTxt1_Defer & " " & $LabelTxt2_Defer, 6, 5, 780, 17) Global $Hours_Defer, $Mins_Defer, $Secs_Defer Global $Form_Update2 = GUICreate("Application Installer - Update2", 515, 401, -1, -1, $WS_POPUP) Global $Pic_Update2 = GUICtrlCreatePic(@ScriptDir & "\ai.update.jpg", 0, 0, 515, 401, $GUI_DISABLE) Global $pheight_Update2 = 129, $pwidth_Update2 = 129, $oIE_Update2, $GUIActiveX_Update2, $gif_Update2, $sizes_Update2 Global $Countdown_Finish1 = 30 Global $Total_Time_Finish1 = $Countdown_Finish1 Global $Form_Finish1 = GUICreate("Application Installer - Finish1", 515, 401, -1, -1, $WS_POPUP) Global $Pic_Finish1 = GUICtrlCreatePic(@ScriptDir & "\ai.finish.jpg", 0, 0, 515, 401, $GUI_DISABLE) Global $Button1_Finish1 = GUICtrlCreateButton("Finish", 352, 363, 72, 22) Global $Button2_Finish1 = GUICtrlCreateButton("Restart", 431, 363, 72, 22) Global $Hours_Finish1, $Mins_Finish1, $Secs_Finish1 Global $Countdown_Finish2 = 30 Global $Total_Time_Finish2 = $Countdown_Finish2 Global $Form_Finish2 = GUICreate("Application Installer - Finish2", 515, 401, -1, -1, $WS_POPUP) Global $Pic_Finish2 = GUICtrlCreatePic(@ScriptDir & "\ai.finish.jpg", 0, 0, 515, 401, $GUI_DISABLE) Global $Button1_Finish2 = GUICtrlCreateButton("Finish", 352, 363, 72, 22) Global $Button2_Finish2 = GUICtrlCreateButton("Restart", 431, 363, 72, 22) Global $Hours_Finish2, $Mins_Finish2, $Secs_Finish2 Global $Label_Sponsor = GUICtrlCreateLabel("* Provided by your IT administration", 290, 7, 300, 19) ;=========================================================================================================== Styles GUICtrlSetBkColor($Label_Sponsor, 0x4B4A48) GUICtrlSetColor($Label_Sponsor, 0xEEEEEE) GUISetFont(10, 0, 0, "Corbel", 2) ;=========================================================================================================== Welcome WinSetOnTop($Form_Welcome, "", $WINDOWS_ONTOP) _Timer_SetTimer($Form_Welcome, 1000, '_Countdown_Welcome') GUISetState(@SW_SHOW, $Form_Welcome) While 1 $Msg_Welcome = GUIGetMsg() Switch $Msg_Welcome Case $GUI_EVENT_CLOSE GUISetState(@SW_HIDE, $Form_Welcome) Exit Case $Button1_Welcome; This is the "Update" button GUISetState(@SW_HIDE, $Form_Welcome) ;=========================================================================================================== Update1 WinSetOnTop($Form_Update1, "", $WINDOWS_ONTOP) _Timer_SetTimer($Form_Update1, 1000, '_Countdown_Update1') GUISetState(@SW_SHOW, $Form_Update1) ; INSTALL SOFTWARE HERE INSTALL SOFTWARE HERE INSTALL SOFTWARE HERE INSTALL SOFTWARE HERE _Main_Update1() While 1 $Msg_Update1 = GUIGetMsg() Switch $Msg_Update1 Case $GUI_EVENT_CLOSE GUISetState(@SW_HIDE, $Form_Update1) Exit EndSwitch Sleep(5000) ExitLoop WEnd ;=========================================================================================================== Finish1 GUISetState(@SW_HIDE, $Form_Update1) WinSetOnTop($Form_Finish1, "", $WINDOWS_ONTOP) _Timer_SetTimer($Form_Finish1, 1000, '_Countdown_Finish1') GUISetState(@SW_SHOW, $Form_Finish1) While 1 $Msg_Finish1 = GUIGetMsg() Switch $Msg_Finish1 Case $GUI_EVENT_CLOSE GUISetState(@SW_HIDE, $Form_Finish1) Exit Case $Button1_Finish1; This is the "Finish" button GUISetState(@SW_HIDE, $Form_Finish1) Exit Case $Button2_Finish1; This is the "Restart" button GUISetState(@SW_HIDE, $Form_Finish1) Shutdown(22) Exit EndSwitch WEnd Exit Case $Button2_Welcome; This is the "Defer" button GUISetState(@SW_HIDE, $Form_Welcome) ;=========================================================================================================== Defer WinSetOnTop($Form_Defer, "", $WINDOWS_ONTOP) _Timer_SetTimer($Form_Defer, 1000, '_Countdown_Defer') GUISetState(@SW_SHOW, $Form_Defer) While 1 $Msg_Defer = GUIGetMsg() Switch $Msg_Defer Case $GUI_EVENT_CLOSE GUISetState(@SW_HIDE, $Form_Defer) Exit Case $Button1_Defer; This is the "Update" button GUISetState(@SW_HIDE, $Form_Defer) ;=========================================================================================================== Update2 WinSetOnTop($Form_Update2, "", $WINDOWS_ONTOP) _Timer_SetTimer($Form_Update2, 1000, '_Countdown_Update2') GUISetState(@SW_SHOW, $Form_Update2) ; INSTALL SOFTWARE HERE INSTALL SOFTWARE HERE INSTALL SOFTWARE HERE INSTALL SOFTWARE HERE _Main_Update2() While 1 $Msg_Update2 = GUIGetMsg() Switch $Msg_Update2 Case $GUI_EVENT_CLOSE GUISetState(@SW_HIDE, $Form_Update2) Exit EndSwitch Sleep(5000) ExitLoop WEnd ;=========================================================================================================== Finish2 GUISetState(@SW_HIDE, $Form_Update2) WinSetOnTop($Form_Finish2, "", $WINDOWS_ONTOP) _Timer_SetTimer($Form_Finish2, 1000, '_Countdown_Finish2') GUISetState(@SW_SHOW, $Form_Finish2) While 1 $Msg_Finish2 = GUIGetMsg() Switch $Msg_Finish2 Case $GUI_EVENT_CLOSE GUISetState(@SW_HIDE, $Form_Finish2) Exit Case $Button1_Finish2; This is the "Finish" button GUISetState(@SW_HIDE, $Form_Finish2) Exit Case $Button2_Finish2; This is the "Restart" button GUISetState(@SW_HIDE, $Form_Finish2) Shutdown(22) Exit EndSwitch WEnd Exit EndSwitch WEnd EndSwitch WEnd Exit ;=========================================================================================================== Functions Func _HawkingHole() ;Disable ALT+F4 key combination EndFunc Func _Countdown_Welcome($Form_Welcome, $Msg_Welcome, $IDTimer_Welcome, $dwTime_Welcome) $Countdown_Welcome -= 1 $percent_value_Welcome = Floor(($Countdown_Welcome / $Total_Time_Welcome) * 100) $percent_value_Welcome = 100 - $percent_value_Welcome If $Countdown_Welcome > 0 Then GUICtrlSetData($Progress_Welcome, $percent_value_Welcome) ElseIf $Countdown_Welcome = 0 Then GUICtrlSetData($Progress_Welcome, $percent_value_Welcome) _Timer_KillTimer($Form_Welcome, $IDTimer_Welcome) ControlClick($Form_Welcome, "", $Button1_Welcome) EndIf EndFunc Func _SecsToTime_Welcome($Sec_Welcome) _TicksToTime_Welcome($Sec_Welcome*1000, $Hours_Welcome, $Mins_Welcome, $Secs_Welcome) Return StringFormat("%2i:%02i", $Mins_Welcome, $Secs_Welcome) EndFunc Func _Main_Update1() $gif_Update1 = @ScriptDir & "\ai.update.gif" If @error Then Exit _GetGifPixWidth_Height_Update1($gif_Update1, $pwidth_Update1, $pheight_Update1) $oIE_Update1 = ObjCreate("Shell.Explorer.2") $GUIActiveX_Update1 = GUICtrlCreateObj($oIE_Update1, 275, 155, 129, 129) $oIE_Update1.navigate ("about:blank") While _IEPropertyGet($oIE_Update1, "busy") Sleep(100) WEnd $oIE_Update1.document.body.background = $gif_Update1 $oIE_Update1.document.body.style.margin = "0" $oIE_Update1.document.body.style.padding = "0" $oIE_Update1.document.body.scroll = "no" $oIE_Update1.document.body.style.border = "0" EndFunc Func _GetGifPixWidth_Height_Update1($s_gif_Update1, ByRef $pwidth_Update1, ByRef $pheight_Update1) If FileGetSize($s_gif_Update1) > 9 Then $sizes_Update1 = FileRead($s_gif_Update1, 10) ConsoleWrite("Gif version: " & StringMid($sizes_Update1, 1, 6) & @LF) $pwidth_Update1 = Asc(StringMid($sizes_Update1, 8, 1)) * 256 + Asc(StringMid($sizes_Update1, 7, 1)) $pheight_Update1 = Asc(StringMid($sizes_Update1, 10, 1)) * 256 + Asc(StringMid($sizes_Update1, 9, 1)) ConsoleWrite($pwidth_Update1 & " x " & $pheight_Update1 & @LF) EndIf EndFunc Func On_WM_SYSCOMMAND_Update1($Form_Update1, $Msg_Update1, $wParam_Update1, $lParam_Update1) If BitAND($wParam_Update1, 0xFFF0) = $SC_MOVE Then Return False Return $GUI_RUNDEFMSG EndFunc Func _Main_Update2() $gif_Update2 = @ScriptDir & "\ai.update.gif" If @error Then Exit _GetGifPixWidth_Height_Update2($gif_Update2, $pwidth_Update2, $pheight_Update2) $oIE_Update2 = ObjCreate("Shell.Explorer.2") $GUIActiveX_Update2 = GUICtrlCreateObj($oIE_Update2, 275, 155, 129, 129) $oIE_Update2.navigate ("about:blank") While _IEPropertyGet($oIE_Update2, "busy") Sleep(100) WEnd $oIE_Update2.document.body.background = $gif_Update2 $oIE_Update2.document.body.style.margin = "0" $oIE_Update2.document.body.style.padding = "0" $oIE_Update2.document.body.scroll = "no" $oIE_Update2.document.body.style.border = "0" EndFunc Func _GetGifPixWidth_Height_Update2($s_gif_Update2, ByRef $pwidth_Update2, ByRef $pheight_Update2) If FileGetSize($s_gif_Update2) > 9 Then $sizes_Update2 = FileRead($s_gif_Update2, 10) ConsoleWrite("Gif version: " & StringMid($sizes_Update2, 1, 6) & @LF) $pwidth_Update2 = Asc(StringMid($sizes_Update2, 8, 1)) * 256 + Asc(StringMid($sizes_Update2, 7, 1)) $pheight_Update2 = Asc(StringMid($sizes_Update2, 10, 1)) * 256 + Asc(StringMid($sizes_Update2, 9, 1)) ConsoleWrite($pwidth_Update2 & " x " & $pheight_Update2 & @LF) EndIf EndFunc Func On_WM_SYSCOMMAND_Update2($Form_Update2, $Msg_Update2, $wParam_Update2, $lParam_Update2) If BitAND($wParam_Update2, 0xFFF0) = $SC_MOVE Then Return False Return $GUI_RUNDEFMSG EndFunc Func _Countdown_Defer($Form_Defer, $Msg_Defer, $IDTimer_Defer, $dwTime_Defer) $Countdown_Defer -= 1 $percent_value_Defer = Floor(($Countdown_Defer / $Total_Time_Defer) * 100) $percent_value_Defer = 100 - $percent_value_Defer If $Countdown_Defer > 0 Then GUICtrlSetData($Progress_Defer, $percent_value_Defer) ElseIf $Countdown_Defer = 0 Then GUICtrlSetData($Progress_Defer, $percent_value_Defer) _Timer_KillTimer($Form_Defer, $IDTimer_Defer) ControlClick($Form_Defer, "Update", $Button1_Defer) EndIf EndFunc Func _SecsToTime_Defer($Sec_Defer) _TicksToTime_Defer($Sec_Defer*1000, $Hours_Defer, $Mins_Defer, $Secs_Defer) Return StringFormat("%2i:%02i", $Mins_Defer, $Secs_Defer) EndFunc