;;Includes #include #include #include #include #include #include #include #include #include Global $SS_CENTER Global $_CountdownTime Global $_Minutes Global $_Seconds Global $TimeTicks Global $TimeLabel Global $_GuiCountDown Global $EnterMinutes Global $EnterSeconds Global $StartButton Global $Minutes Global $Seconds Global $_GuiEnterTime Dim $aPanelCSV[0] ;Main function to trigger everything Main() Func Main() EnterTimeGUI() EnterTime() EndFunc Func PanelCount() ;stuff that works in the real script EndFunc ;Primary function for entering in the countdown duration Func EnterTimeGUI() ;;Create a GUI $_GuiEnterTime = GUICreate ( "Enter Start Time", 300, 150) Opt("GUIOnEventMode", 0) GUISetBkColor ( 0xFFFFFF ) GUISetFont(10,0,0) $EnterLabel = GUICtrlCreateLabel ( "Minutes", 100,15,100,35) $EnterLabel = GUICtrlCreateLabel ( "Seconds", 160,15,100,35) GUISetFont(13.5,0,0) $EnterMinutes = GUICtrlCreateInput ("",105,35,45,35,$ES_NUMBER) $EnterSeconds = GUICtrlCreateInput ("",155,35,45,35,$ES_NUMBER) GUISetFont(12,0,0) $StartButton = GUICtrlCreateButton ("Start",110,80,80,50) GUISetState (@SW_SHOW,$_GuiEnterTime) EndFunc Func EnterTime() GUISetState (@SW_SHOW,$_GuiEnterTime) Opt("GUIOnEventMode", 0) While 1 $MSG = GUIGetMsg() Select Case $MSG = $GUI_EVENT_CLOSE ;Exit MsgBox(4000,"DEBUG: Enter Time","enter time close button pressed") ;;Start button for countdown Case $MSG = $StartButton $Minutes = GUICtrlRead($EnterMinutes) $Seconds = GUICtrlRead($EnterSeconds) ;Math for the WallTime and local countdown functions $Paneltime = (((60 * $Minutes) + $Seconds)) $_CountdownTime =(((60000 * $Minutes) + (1000 * $Seconds))+1000) Sleep(100) GUISetState (@SW_HIDE,$_GuiEnterTime) ;;Function starts the countdown timer on the WallTime panels PanelCountDown() ;;starts the function for local countdown CountDownGUI() ComputerCountDown() EndSelect WEnd EndFunc #cs Local countdown--this was mostly taken from Wakillon's post in April of 2011, then modified for my use case. Full credit to Wakillon for this part. https://www.autoitscript.com/forum/topic/127667-how-to-create-a-countdown-timer-in-autoit/ #ce Func CountDownGUI() ;;Countdown GUI $_GuiCountDown = GUICreate ( "CountDown...", 500, 200, @DesktopWidth/2 -250, @DesktopHeight/2 -100) GUISwitch ($_GuiCountDown) Opt("GUIOnEventMode", 1) GUISetOnEvent($GUI_EVENT_CLOSE, "StopCountdown") GUISetBkColor ( 0xFFFFFF ) $TimeLabel = GUICtrlCreateLabel ( "", 35, -10, 480, 180, $SS_CENTER ) GUICtrlSetFont ( -1, 125, 800 ) GUISetState (@SW_SHOW,$_GuiCountDown) ;WinSetOnTop ( $_GuiCountDown, "", 1 ) $TimeTicks = TimerInit ( ) EndFunc Func ComputerCountDown() While 1 ;;calls the function to begin the countdown Check ( ) Sleep (200) WEnd EndFunc Func Check ( ) $_CountdownTime -= TimerDiff ( $TimeTicks ) $TimeTicks = TimerInit ( ) Local $_MinCalc = Int ( $_CountdownTime / ( 60 * 1000 ) ), $_SecCalc = $_CountdownTime - ( $_MinCalc * 60 * 1000 ) $_SecCalc = Int ( $_SecCalc / 1000 ) If $_MinCalc <= 0 And $_SecCalc <= 0 Then ;;steps through one second at a time Sleep ( 250 ) ;;when it's done it removes the GUI and goes back to the entry interface GUIDelete ($_GuiCountDown) EnterTime() Else ;;changes colors of the GUI for the last 10 seconds If $_MinCalc <> $_Minutes Or $_SecCalc <> $_Seconds Then $_Minutes = $_MinCalc $_Seconds = $_SecCalc GUICtrlSetData ( $TimeLabel, StringFormat ( "%02u" & ":" & "%02u", $_Minutes, $_Seconds ) ) If $_Minutes = 0 And $_Seconds <= 10 Then GUISetBkColor ( 0xA093FF, $_GuiCountDown ) EndIf EndIf EndIf EndFunc Func PanelCountdown() ;;this part works fine, part of an external system I'm triggering via UDP sends EndFunc Func StopCountdown() MSGBox(4000,"DEBUG: Countdown Close","Countdown close button pressed") ;more UDP stuff that works fine GUIDelete($_GuiCountDown) ;;Back to the input interface EnterTime() EndFunc