Jump to content
Sign in to follow this  
tommytx

Way to control two different percentage bars from one GUI.

Recommended Posts

tommytx

Is there anyway to have two individual progress bars controlled by two different sources in the same gui.. as shown in the code below. For example I want to set up say two timers and have each one fire the bars separately at different times... actually what I am doing is reading an external page that is counting down and I am then setting my local count down to match the counting on the page but using a simple autoit timed to make this work would be fine... then its a simple manner of checking the counter on the external webpage and setting my progress bar to match it each second... I just need to know how to make more than one progress bar show at the same time and be controlled by a separate signal. Actually there will be 4 to 6 of these progress bars displaying at the same time.. and they can be separate or on the same page... same page is best... just 4 in a row on one page like below.

Progress Bar 1

Progress Bar 2

progress Bar 3

etc....

If you run my code below you will see that only the second Progress Bar shows and the first one is written over... I suppose. I need up to 4 to show at once and be controlled by separate sources.

#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
ProgressOn("System 1", "Counter 1", "100 percent")
ProgressOn("System 2", "Counter 2", "100 percent")
for $y = 1 to 9
; ProgressSet( 100, 10)
For $i = 100 to 10 step -10
    ProgressSet( $i, $i/10)
     sleep(1000)
Next
; Sleep(1000)
ProgressSet( 0, 0)
Sleep(1000)
Next
sleep(5000)
ProgressSet(100 , "Done", "Complete")
sleep(500)
ProgressOff()
Edited by tommytx

Share this post


Link to post
Share on other sites
fett8802

I just wrote a working example. It's a progress bar clock!

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

Opt("GUIOnEventMode", 1)

#Region
$gMain = GUICreate("Progress Bar Clock", 633, 106, 192, 124)
    GUISetOnEvent($GUI_EVENT_CLOSE, "gMainClose")
$lHours = GUICtrlCreateLabel("Hours:", 8, 8, 35, 17)
$lMinutes = GUICtrlCreateLabel("Minutes:", 8, 32, 44, 17)
$lSeconds = GUICtrlCreateLabel("Seconds:", 9, 56, 49, 17)
$lMillis = GUICtrlCreateLabel("Milliseconds:", 8, 80, 64, 17)
$pHours = GUICtrlCreateProgress(80, 8, 545, 12)
$pMinutes = GUICtrlCreateProgress(80, 32, 545, 12)
$pSeconds = GUICtrlCreateProgress(80, 56, 545, 12)
$pMillis = GUICtrlCreateProgress(80, 80, 545, 12)
GUISetState(@SW_SHOW)
#EndRegion

While 1
    GUICtrlSetData($pHours, (@HOUR / 24) * 100)
    GUICtrlSetData($pMinutes, (@MIN / 60) * 100)
    GUICtrlSetData($pSeconds, (@SEC / 60) * 100)
    GUICtrlSetData($pMillis, (@MSEC / 1000) * 100)

    Sleep(100)
WEnd

Func gMainClose()
    Exit
EndFunc

Hope this helps!

- Fett

Edited by fett8802

[sub]My UDF[/sub][sub] - Basics and Time extensions. Great for those new at AutoIt, also contains some powerful time extensions for pros.[/sub][sub]ScrabbleIt[/sub][sub] - Scrabble done in pure AutoIt. (In Progress)[/sub][sub]Nerd Party Extreme | My Portfolio | [email="fett8802@gmail.com"]Contact Me[/email][/sub]

Share this post


Link to post
Share on other sites
tommytx

thank you fett... that is exactly what I needed... I can easily modify that to work..

Thanks also Admiral... but with my weak knowledge.. telling me to make myself a GUI would not work for me as I only speak negative GUI.. that means I know less than nothing...

Share this post


Link to post
Share on other sites
AlmarM

I just wrote a working example. It's a progress bar clock!

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

Opt("GUIOnEventMode", 1)

#Region
$gMain = GUICreate("Progress Bar Clock", 633, 106, 192, 124)
    GUISetOnEvent($GUI_EVENT_CLOSE, "gMainClose")
$lHours = GUICtrlCreateLabel("Hours:", 8, 8, 35, 17)
$lMinutes = GUICtrlCreateLabel("Minutes:", 8, 32, 44, 17)
$lSeconds = GUICtrlCreateLabel("Seconds:", 9, 56, 49, 17)
$lMillis = GUICtrlCreateLabel("Milliseconds:", 8, 80, 64, 17)
$pHours = GUICtrlCreateProgress(80, 8, 545, 12)
$pMinutes = GUICtrlCreateProgress(80, 32, 545, 12)
$pSeconds = GUICtrlCreateProgress(80, 56, 545, 12)
$pMillis = GUICtrlCreateProgress(80, 80, 545, 12)
GUISetState(@SW_SHOW)
#EndRegion

While 1
    GUICtrlSetData($pHours, (@HOUR / 24) * 100)
    GUICtrlSetData($pMinutes, (@MIN / 60) * 100)
    GUICtrlSetData($pSeconds, (@SEC / 60) * 100)
    GUICtrlSetData($pMillis, (@MSEC / 1000) * 100)

    Sleep(100)
WEnd

Func gMainClose()
    Exit
EndFunc

Hope this helps!

- Fett

That clock is actually really cool. Haha :)

Minesweeper

A minesweeper game created in autoit, source available.

_Mouse_UDF

An UDF for registering functions to mouse events, made in pure autoit.

2D Hitbox Editor

A 2D hitbox editor for quick creation of 2D sphere and rectangle hitboxes.

Share this post


Link to post
Share on other sites
BrewManNH

Definitely a geek's clock for sure. :) It's a great demo.


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

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  

×