Jump to content

Timer countdown help


Recommended Posts

So i have this little app, what i want to do is: when i click start it will start a timer, and so on for different progressbars

however I am not sure why the time will sometimes stop for 1-2 sec then continue

another problem i am having is clicking multiple timers will tend to lag the previous timers, is there a better way to go about this?

#include <Array.au3>
#include <ProgressConstants.au3>
#include <GUIConstantsEx.au3>

$Form1_1 = GUICreate("Form1", 450, 150)

Dim $Progress[7]
$Progress[1] = GUICtrlCreateProgress(80, 10, 150, 16, $PBS_SMOOTH )
$Progress[2] = GUICtrlCreateProgress(80, 30, 150, 16, $PBS_SMOOTH )
$Progress[3] = GUICtrlCreateProgress(80, 50, 150, 16, $PBS_SMOOTH )
$Progress[4] = GUICtrlCreateProgress(80, 70, 150, 16, $PBS_SMOOTH )
$Progress[5] = GUICtrlCreateProgress(80, 90, 150, 16, $PBS_SMOOTH )
$Progress[6] = GUICtrlCreateProgress(80, 110, 150, 16, $PBS_SMOOTH )

Dim $Label[7]
$Label[1] = GUICtrlCreateInput("", 8, 10, 60, 17)
$Label[2] = GUICtrlCreateInput("", 8, 30, 60, 17)
$Label[3] = GUICtrlCreateInput("", 8, 50, 60, 17)
$Label[4] = GUICtrlCreateInput("", 8, 70, 60, 17)
$Label[5] = GUICtrlCreateInput("", 8, 90, 60, 17)
$Label[6] = GUICtrlCreateInput("", 8, 110, 60, 17)

Dim $Button[7]
$Button[1] = GUICtrlCreateButton("Start", 240, 10, 50, 17)
$Button[2] = GUICtrlCreateButton("Start", 240, 30, 50, 17)
$Button[3] = GUICtrlCreateButton("Start", 240, 50, 50, 17)
$Button[4] = GUICtrlCreateButton("Start", 240, 70, 50, 17)
$Button[5] = GUICtrlCreateButton("Start", 240, 90, 50, 17)
$Button[6] = GUICtrlCreateButton("Start", 240, 110, 50, 17)

Dim $Num[7]

$Duration = 10

GUISetState(@SW_SHOW)
$Check = False
While 1
    $msg = GUIGetMsg()
    $Add = 0
    If $msg = $GUI_EVENT_CLOSE Then Exit
    For $a = 1 to UBound($Progress)-1
        If $msg = $Button[$a] Then
            GUICtrlSetData($Progress[$a], 100)
            $Num[$a] = 100
            $Change = TimerInit()
        EndIf
    Next
    If $Check = True Then $Change1 = TimerDiff($Change)
    For $a = 1 to UBound($Progress)-1
        If GUICtrlRead($Progress[$a]) > 0 Then
            Sleep(1)
            $New = $Num[$a] - (($Change1/1000)/$Duration)*100
            GUICtrlSetData($Progress[$a], $New)
            $Num[$a] = $New
            ConsoleWrite($Num[$a]&@LF)
        EndIf
        $Check = True
    Next
    $Change = TimerInit()
WEnd
Link to comment
Share on other sites

The example of a progress using '_Timer_SetTimer' might be helpfull, find it in the helpfile udf > Timmers management > _Timer_SetTimer.

GDIPlusDispose - A modified version of GDIPlus that auto disposes of its own objects before shutdown of the Dll using the same function Syntax as the original.EzMySql UDF - Use MySql Databases with autoit with syntax similar to SQLite UDF.
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...