frankpintosr Posted April 23, 2009 Share Posted April 23, 2009 Hello All, I have a script that someone made and possted here, and I editied a bit for my needs. It was a countdown to restart, but I just need a window with progress bar that acuratly moves along with a countdown timer displayed too. Once time is up, the program exits. It is working fine except, the progress bar is not updating, what am I missing here? Thanks!! expandcollapse popup#include <StaticConstants.au3> #include <WindowsConstants.au3> #include <GUIConstantsEx.au3> #include <Timers.au3> #include <Date.au3> #include <ProgressConstants.au3> Global $iCountdown = 5; Sets the time-out in seconds $iTotal_Time = 0 $Prompt = 0 $Form1 = GUICreate("Reminaing Time To Continue", 415, 145, -1, -1, BitOR($WS_CAPTION, $WS_POPUP, $WS_BORDER, $WS_CLIPSIBLINGS), $WS_EX_WINDOWEDGE); Creates GUI Window $Progress = GUICtrlCreateProgress(10, 65, 395, 15, $PBS_SMOOTH); Creates Progress Bar GUICtrlSetColor($Progress, 0xff0000); Sets Progress Bar Color $Label1 = GUICtrlCreateLabel("", 10, 10, 405, 25) GUISetState(@SW_SHOW) _Timer_SetTimer($Form1, 1000, '_Countdown') While 1 $nMsg = GUIGetMsg() WEnd ;-------------Functions Below this Line--------------------------- Func _Countdown($hWnd, $iMsg, $iIDTimer, $dwTime) $iCountdown -= 1 $percent_value = Floor(($iCountdown / $iTotal_Time) * 100) $percent_value = 100 - $percent_value If $iCountdown > 0 Then GUICtrlSetData($Label1, $Prompt & _SecsToTime($iCountdown) & " Time Remaining to Continue") GUICtrlSetData($Progress, $percent_value) ElseIf $iCountdown = 0 Then GUICtrlSetData($Label1, $Prompt & _SecsToTime($iCountdown) & " Time Remaining to Continue") GUICtrlSetData($Progress, $percent_value) Exit EndIf EndFunc ;==>_Countdown Func _SecsToTime($iSecs) Local $iHours, $iMins, $iSec_s _TicksToTime($iSecs*1000,$iHours,$iMins,$iSec_s) Return StringFormat("%01i:%02i",$iMins, $iSec_s) EndFunc Link to comment Share on other sites More sharing options...
ProgAndy Posted April 23, 2009 Share Posted April 23, 2009 You never set $iTotal_Time to the total time I think, in the beginning, it should be the same as the Counter. *GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes Link to comment Share on other sites More sharing options...
Valuater Posted April 23, 2009 Share Posted April 23, 2009 Working... expandcollapse popup#include <StaticConstants.au3> #include <WindowsConstants.au3> #include <GUIConstantsEx.au3> #include <Timers.au3> #include <Date.au3> #include <ProgressConstants.au3> Global $iCountdown = 6; Sets the time-out in seconds $iTotal_Time = 5 $Prompt = 0 $Form1 = GUICreate("Reminaing Time To Continue", 415, 145, -1, -1, BitOR($WS_CAPTION, $WS_POPUP, $WS_BORDER, $WS_CLIPSIBLINGS), $WS_EX_WINDOWEDGE); Creates GUI Window $Progress = GUICtrlCreateProgress(10, 65, 395, 15, $PBS_SMOOTH); Creates Progress Bar GUICtrlSetColor($Progress, 0xff0000); Sets Progress Bar Color $Label1 = GUICtrlCreateLabel("", 10, 10, 405, 25) GUISetState(@SW_SHOW) _Timer_SetTimer($Form1, 1000, '_Countdown') While 1 $nMsg = GUIGetMsg() WEnd ;-------------Functions Below this Line--------------------------- Func _Countdown($hWnd, $iMsg, $iIDTimer, $dwTime) $iCountdown -= 1 $percent_value = (($iCountdown / $iTotal_Time) * 100) If $iCountdown > 0 Then GUICtrlSetData($Label1, $Prompt & _SecsToTime($iCountdown) & " Time Remaining to Continue") GUICtrlSetData($Progress, $percent_value) ElseIf $percent_value <= 0 Then GUICtrlSetData($Label1, $Prompt & _SecsToTime($iCountdown) & " Time Remaining to Continue") GUICtrlSetData($Progress, $percent_value) Exit EndIf EndFunc ;==>_Countdown Func _SecsToTime($iSecs) Local $iHours, $iMins, $iSec_s _TicksToTime($iSecs*1000,$iHours,$iMins,$iSec_s) Return StringFormat("%01i:%02i",$iMins, $iSec_s) EndFunc 8) Link to comment Share on other sites More sharing options...
frankpintosr Posted April 23, 2009 Author Share Posted April 23, 2009 You never set $iTotal_Time to the total time I think, in the beginning, it should be the same as the Counter.DUH!!! Thanks that is what I missed!! Link to comment Share on other sites More sharing options...
mentosan Posted May 8, 2009 Share Posted May 8, 2009 Hi there ! I want to use your script at the beginning of my script but it will exit as soon as the time is up. Can you help me ? Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now