# Multi Progress bars

## Recommended Posts

Hello

I am wondering what would be the best way to do this, since progress bars are maxed at 100 (max number) say you have three of them the first two of them are used to calculate certain information and the third one is the total progress how would you fine out the total progress?

I hope this example will help I am not sure how to word it properly, in my example it is just adding the two of them to calculate the total progress.

#include <GUIConstants.au3>
\$GUI = GUICreate("Form1", 150, 400)
\$Progress1 = GUICtrlCreateProgress(0, 0, 150, 15)
GUICtrlSetData(\$Progress1 , 50)
\$Progress2 = GUICtrlCreateProgress(0, 20, 150, 15)
GUICtrlSetData(\$Progress2 , 50)
\$Progress3 = GUICtrlCreateProgress(0, 40, 150, 15)
GUISetState(@SW_SHOW)
Sleep(1000)
While 1
\$nMsg = GUIGetMsg()
Switch \$nMsg
Case \$GUI_EVENT_CLOSE
Exit

EndSwitch
WEnd

##### Share on other sites

You almost had it, but since you added two percentages together and want to find when both are done, you needed to divide by 2:

#include <GUIConstants.au3>
\$GUI = GUICreate("Form1", 150, 400)
\$Progress1 = GUICtrlCreateProgress(0, 0, 150, 15)
\$Progress2 = GUICtrlCreateProgress(0, 20, 150, 15)
\$Progress3 = GUICtrlCreateProgress(0, 40, 150, 15)
GUISetState(@SW_SHOW)
Sleep(1000)
\$avar = 0
While 1
\$nMsg = GUIGetMsg()
Switch \$nMsg
Case \$GUI_EVENT_CLOSE
Exit
EndSwitch
\$avar += 1
Sleep(100)
If \$avar < 101 Then
GUICtrlSetData(\$Progress1 , \$avar)
EndIf
If \$avar > 100 Then
GUICtrlSetData(\$Progress2 , \$avar - 100)
EndIf
MsgBox(0, "Progress", "Both pregress bars are done" )
GUICtrlSetData( \$Progress1, 0 )
GUICtrlSetData( \$Progress2, 0 )
GUICtrlSetData( \$Progress3, 0 )
\$avar = 0
EndIf
WEnd

## Create an account

Register a new account