Page 1 of 1

Multiple progress bars/loops

Posted: 17 Mar 2018, 14:43
by choui
Hi, I'm having trouble getting multiple progress bars to run simultaneously in a gui.

Here is an example, I want them to work as they do now (restarting themselves when i press the same key), but I don't want them to stop/delay eachother.
i.e pressing 2doesn't stop 1 etc.

Code: Select all

Gui, Main: New
Gui, Main: Show, w450 h450

Gui, 1: +parentMain
Gui, 1: Color, c292929
Gui, 1: Add, Progress, x0 y0 w300 h20 cGreen +Border vGreen
Gui, 1: Show, x5 y5 w300 h20

Gui, 2: +parentMain
Gui, 2: Color, c292929
Gui, 2: Add, Progress, x0 y0 w300 h20 cBlue +Border vBlue
Gui, 2: Show, x5 y50 w300 h20

Gui, 3: +parentMain
Gui, 3: Color, c292929
Gui, 3: Add, Progress, x0 y0 w300 h20 cBlack +Border vBlack
Gui, 3: Show, x5 y95 w300 h20
Return

1::
GuiControl, 1:, Green, 0
KeyWait, 1
Loop 100 
{
	GuiControl, 1:, Green, +1
	KeyWait, 1, D T0   
	
	If (!ErrorLevel)
		GoTo, 1
	Sleep, 1
}
GuiControl, 1:, Green, 0
Return

2::
GuiControl, 2:, Blue, 0
KeyWait, 2
Loop 100 
{
	GuiControl, 2:, Blue, +1
	KeyWait, 2, D T0   
	If (!ErrorLevel)
		Goto, 2
	Sleep, 1
}
GuiControl, 2:, Blue, 0
Return

3::
GuiControl, 3:, Black, 0
KeyWait, 3
Loop 100 
{
	GuiControl, 3:, Black, +1
	KeyWait, 3, D T0   
	If (!ErrorLevel)
		Goto, 3
	Sleep, 1
}
GuiControl, 3:, Black, 0
Return

ESC::ExitApp
Any help or guidance I can get are really appreciated, thanks

Re: Multiple progress bars/loops

Posted: 18 Mar 2018, 13:24
by noname
I guess a settimer would solve it if the timing is not too critical.

example:

Code: Select all



Gui, Main: New
Gui, Main: Show, w450 h450

Gui, 1: +parentMain
Gui, 1: Color, c292929
Gui, 1: Add, Progress, x0 y0 w300 h20 cGreen +Border vGreen
Gui, 1: Show, x5 y5 w300 h20

Gui, 2: +parentMain
Gui, 2: Color, c292929
Gui, 2: Add, Progress, x0 y0 w300 h20 cBlue +Border vBlue
Gui, 2: Show, x5 y50 w300 h20

Gui, 3: +parentMain
Gui, 3: Color, c292929
Gui, 3: Add, Progress, x0 y0 w300 h20 cBlack +Border vBlack
Gui, 3: Show, x5 y95 w300 h20
Return


1::
counter1:=0
settimer,loop1,100
return


loop1:
counter1++
GuiControl, 1:, Green, % counter1

if (counter1=100)
  {
  SetTimer, loop1,off
  counter1:=0
  }
return


2::
counter2:=0
settimer,loop2,100
return


loop2:
counter2++
GuiControl, 2:, Blue, % counter2

if (counter2=100)
  {
  SetTimer, loop2,off
  counter2:=0
  }
return


3::
counter3:=0
settimer,loop3,100
return


loop3:
counter3++
GuiControl, 3:, Black, % counter3

if (counter3=300)
  {
  SetTimer, loop3,off
  counter3:=0
  }
return

ESC::ExitApp