Jump to content

Progress bar frustration


B3EAST
 Share

Recommended Posts

My progress bar only does 3/4 of the bar and then it says it is finished.

I am pretty sure this should work but the only thing i can think of is my formula is wrong for the calculation but dont see it.

any help plz.

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


Global $Time = InputBox(""," Type time in minutes needed for amount" & @CRLF & @CRLF & "Default is for 2 minutes",2) * 60

GUICreate("timer count up",300,100)
$Prog1 = GUICtrlCreateProgress(10,10,200,20)
GUICtrlSetColor(-1, 32250)
$button1 = GUICtrlCreateButton("Start", 75, 70, 70, 20)
GUISetState()
$wait = 1000  ;time delay in seconds
Do
    $msg = GUIGetMsg()
            If $msg = $button1 Then
                For $i = 0 To $Time
                    GUICtrlSetData($Prog1,$i / $Time *100)
                    Sleep($wait)
                    If GUICtrlRead($Prog1) = $Time Then
                        MsgBox(0,"DONE","Done")
                        Exit
                    EndIf
                Next
            EndIf
    Sleep(20)
Until  $msg = $GUI_EVENT_CLOSE
Link to comment
Share on other sites

  • Developers

Why do you have this test?:

If GUICtrlRead($Prog1) = $Time Then
   MsgBox(0,"DONE","Done")
   Exit
EndIf
You compare the entered time against the percentatge the progressbar is set to which is 0-100.

Think this should do what you want:

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


Global $Time = InputBox("", " Type time in minutes needed for amount" & @CRLF & @CRLF & "Default is for 2 minutes", 2) * 60

GUICreate("timer count up", 300, 100)
$Prog1 = GUICtrlCreateProgress(10, 10, 200, 20)
GUICtrlSetColor(-1, 32250)
$button1 = GUICtrlCreateButton("Start", 75, 70, 70, 20)
GUISetState()
$wait = 1000 ;time delay in seconds
Do
    $msg = GUIGetMsg()
    If $msg = $button1 Then
        For $i = 0 To $Time
            GUICtrlSetData($Prog1, $i / $Time * 100)
            Sleep($wait)
        Next
        MsgBox(0, "DONE", "Done")
        Exit
    EndIf
    Sleep(20)
Until $msg = $GUI_EVENT_CLOSE

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

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...