Jump to content
Sign in to follow this  
B3EAST

Progress bar frustration

Recommended Posts

B3EAST

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

Share this post


Link to post
Share on other sites
Jos

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

Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
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
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.