Sign in to follow this  
Followers 0
Slythfox

Progress Bar Problem

5 posts in this topic

What I want to do is simple: a function that increases a progress bar by a certain amount. Seems simple, but I can't figure out how to get it to work. Any ideas?

Share this post


Link to post
Share on other sites



The helpfile says:

ProgressOn("Progress Meter", "Increments every second", "0 percent")
For $i = 10 to 100 step 10
    sleep(1000)
    ProgressSet( $i, $i & " percent")
Next
ProgressSet(100 , "Done", "Complete")
sleep(500)
ProgressOff()

Share this post


Link to post
Share on other sites

The helpfile says:

ProgressOn("Progress Meter", "Increments every second", "0 percent")
For $i = 10 to 100 step 10
    sleep(1000)
    ProgressSet( $i, $i & " percent")
Next
ProgressSet(100 , "Done", "Complete")
sleep(500)
ProgressOff()
Not that kind of progress bar. I guess I failed to say I meant a progress meter via the GUI, so I can integrate it with a program already using Windows GUI stuff. I don't want it as a splash screen.

Share this post


Link to post
Share on other sites

Ok, under GUICtrlCreateProgress:

#include <GUIConstants.au3>

GUICreate("My GUI Progressbar",220,100, 100,200)
$progressbar1 = GUICtrlCreateProgress (10,10,200,20)
GUICtrlSetColor(-1,32250); not working with Windows XP Style
$progressbar2 = GUICtrlCreateProgress (10,40,200,20,$PBS_SMOOTH)
$button = GUICtrlCreateButton ("Start",75,70,70,20)
GUISetState ()

$wait = 20; wait 20ms for next progressstep
$s = 0; progressbar-saveposition
do
$msg = GUIGetMsg()
If $msg = $button Then
    GUICtrlSetData ($button,"Stop")
    For $i = $s To 100
    If GUICtrlRead($progressbar1) = 50 Then Msgbox(0,"Info","The half is done...", 1)
    $m = GUIGetMsg ()
    
    If $m = -3 Then ExitLoop
    
    If $m = $button Then
      GUICtrlSetData ($button,"Next")
      $s = $i;save the current bar-position to $s
      ExitLoop
    Else
        $s=0
      GUICtrlSetData ($progressbar1,$i)
      GUICtrlSetData ($progressbar2,(100 - $i))
      Sleep($wait)
    EndIf
    Next
    if $i >100 then
;      $s=0
        GUICtrlSetData ($button,"Start")
    endif
EndIf
until $msg = $GUI_EVENT_CLOSE

Share this post


Link to post
Share on other sites

I finally got it. This script doesn't really work as a script alone, but it works in the program I need it for:

#include <GUIConstants.au3>

GUICreate("My GUI Progressbar",220,100, 100,200)
$progressbar1 = GUICtrlCreateProgress (10,10,200,20)
$button = GUICtrlCreateButton ("Start",75,70,70,20)
GUICtrlSetOnEvent($button,"Progr")
GUISetState ()

Func Progr()
 GUICtrlSetData ($progressbar1, 10)
EndFunc

while 1
 sleep(1000)
Wend
I'm not sure why this script doesn't really "work," but since I got it to work with the program I needed it for, I don't really care if it doesn't work.

Thanks for helping.

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  
Followers 0