Search the Community
Showing results for tags 'Gui Timer'.
-
I am building a pretty complicated script that will install internet explorer 10 both offline and online and that part has been done, but since I am in an enterprise environment here this install will be going out to everyone in the company, especially senior executive officers so I do not want to make anyone angry. My goal is to ask the user if they want to reboot right away and reboot if the user agrees, but if they do not then the gui timer that I have compiled with a pop up counting down from 8 hours, but this also gives the user yet again another chance to postpone the reboot. If they do postpone the gui should sleep for 4 hours then pop up again. Then with 30 minutes remaining before the reboot this gui should pop up again. I have the timer down, but I cannot seem to to my script to call the timer up back after i tell it to sleep. Does anyone have any clue how I could achieve this? Here is the code if you have any ideas. Thank you. #include <GUIConstantsEx.au3> #include <GUIConstants.au3> ;#include <StaticConstants.au3> ;Start reboot prompt If $cmdLine[0] = 0 then ;Set up the reboot window with the default settings $TimeToReboot = 480 ;8 hours $WinTitle = "IT" $InfoText = "Internet Explorer has been installed and requires the PC to restart. If the PC does not restart it will automatically restart in 8 hours." ;exit -1 ;not all arguments are present, reboot ElseIf $cmdLine[0] = 3 then ;Set the reboot window with the command line options $TimeToReboot = $cmdLine[1] $WinTitle = $cmdLine[2] $InfoText = $cmdLine[3] EndIf ;add the return character $InfoText = StringReplace($InfoText,"\n",@CRLF) ;set up the timer and variables $TimeToReboot *= 60 ;convert it to seconds $startTime = TimerInit() $TimerCount = int(TimerDiff($startTime) / 1000) ;return the time in seconds $PrevTime = $TimerCount $tHour = StringFormat("%02d",int(($TimeToReboot - $TimerCount) / 8 * 60 / 60)) $tMin = StringFormat("%02d",int(($TimeToReboot - $TimerCount - ($tHour * 60 * 60)) / 60)) $tSec = StringFormat("%02d",int($TimeToReboot - $TimerCount - ($tHour * 60 * 60) - ($tMin * 60))) ;msgbox(64,"num of args", $cmdLine[0] & @crlf & $cmdLine[1] & @crlf & $cmdLine[2] & @crlf & $cmdLine[3]) ;number of arguments #Region ### START Koda GUI section ### Form= $Form1 = GUICreate($WinTitle, 418, 250, 198, 137) $lblInformation = GUICtrlCreateLabel($InfoText, 16, 16, 386, 146, $WS_VSCROLL, $WS_EX_STATICEDGE) $lblTimerlbl = GUICtrlCreateLabel("Your PC will automatically restart in:", 16, 182, 200, 17) $lblTimer = GUICtrlCreateLabel($tHour & ":" & $tMin & ":" & $tSec, 216, 182, 60, 17) $btnPostone = GUICtrlCreateButton("Postpone", 180, 200, 107, 25, 0) $btnReboot = GUICtrlCreateButton("Restart Now", 296, 200, 107, 25, 0) GUISetState(@SW_SHOW) GUICtrlSetState($lblInformation,$GUI_FOCUS) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() ;do the timer stuff $TimerCount = int(TimerDiff($startTime) / 1000) ;return the time in seconds if $TimeToReboot - $TimerCount <= 0 Then Shutdown(6) ;Force a reboot Exit EndIf if $PrevTime <> $TimerCount Then ;update the counter $tHour = StringFormat("%02d",int(($TimeToReboot - $TimerCount) / 60 / 60)) $tMin = StringFormat("%02d",int(($TimeToReboot - $TimerCount - ($tHour * 60 * 60)) / 60)) $tSec = StringFormat("%02d",int($TimeToReboot - $TimerCount - ($tHour * 60 * 60) - ($tMin * 60))) ;Set the label GUICtrlSetData($lblTimer,$tHour & ":" & $tMin & ":" & $tSec) ;bring to front and restore window to inform the user its close to reboot time at certain intervals if $TimeToReboot - $TimerCount = 1800 then ;30 minutes left, restore and bring to front GUICtrlSetState($lblInformation,$GUI_FOCUS) GUISetState(@SW_RESTORE) EndIf if $TimeToReboot - $TimerCount = 600 then ;10 minutes left, restore and bring to front GUICtrlSetState($lblInformation,$GUI_FOCUS) GUISetState(@SW_RESTORE) EndIf if $TimeToReboot - $TimerCount = 30 then ;30 seconds left, restore and bring to front GUICtrlSetState($lblInformation,$GUI_FOCUS) GUISetState(@SW_RESTORE) EndIf ;Set the previous time $PrevTime = $TimerCount EndIf Switch $nMsg Case $GUI_EVENT_CLOSE ;Exit Case $btnReboot Shutdown(6) ;force reboot the system Case $btnPostone;make reboot sleep $TimeToReboot Sleep(3000) EndSwitch WEnd ;EndIf