Sign in to follow this  
Followers 0
Kalin

General use for Progress Bars?

18 posts in this topic

#1 ·  Posted (edited)

So I've noticed that progress bars aren't really that useful (or are they).

So I'm asking you guys if you can elaborate about some uses of progress bars, and some examples with them being used in a script (useful wise).

Please, and thank you.

~Solo~

Edited by Kalin

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

A bike is not a very useful transport vehicle. (context: if your thinking about going shopping in a other city.)

Progress bars suffers from the same problem.

There best(or only) used in (time related) situations where you now in advanced how much(min,max,->loop) needs to be done.

How to use them dependent on the situation as there Gui intensive(cpu wise) objects. (Low count with Long workload(time per looped item), or High Count with Short workload.)

If you have some specific situation thats giving you a specific problem ...

Edited by MvGulik

"Straight_and_Crooked_Thinking" : A "classic guide to ferreting out untruths, half-truths, and other distortions of facts in political and social discussions."
"The Secrets of Quantum Physics" : New and excellent 2 part documentary on Quantum Physics by Jim Al-Khalili. (Dec 2014)

"Believing what you know ain't so" ...

Knock Knock ...
 

Share this post


Link to post
Share on other sites

A bike is not a very useful transport vehicle. (context: if your thinking about going shopping in a other city.)

Progress bars suffers from the same problem.

There best(or only) used in (time related) situations where you now in advanced how much(min,max,->loop) needs to be done.

How to use them dependent on the situation as there Gui intensive(cpu wise) objects. (Low count with Long workload(time per looped item), or High Count with Short workload.)

If you have some specific situation thats giving you a specific problem ...

Pretty accurate...

Any code example(s)?

;)

:)

Share this post


Link to post
Share on other sites

If you have some specific situation thats giving you a specific problem ...

... than there are plenty of (other) forum users that might supply some code examples.


"Straight_and_Crooked_Thinking" : A "classic guide to ferreting out untruths, half-truths, and other distortions of facts in political and social discussions."
"The Secrets of Quantum Physics" : New and excellent 2 part documentary on Quantum Physics by Jim Al-Khalili. (Dec 2014)

"Believing what you know ain't so" ...

Knock Knock ...
 

Share this post


Link to post
Share on other sites

If you have some specific situation thats giving you a specific problem ...

... than there are plenty of (other) forum users that might supply some code examples.

well I did ask for a code example(s) in the intro, but k.

Thanks for helping.

;)

Share this post


Link to post
Share on other sites

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

Opt('MustDeclareVars', 1)

Example()

Func Example()
    Local $progressbar1, $progressbar2, $button, $wait, $s, $msg, $m
    
    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
EndFunc   ;==>Example


"Straight_and_Crooked_Thinking" : A "classic guide to ferreting out untruths, half-truths, and other distortions of facts in political and social discussions."
"The Secrets of Quantum Physics" : New and excellent 2 part documentary on Quantum Physics by Jim Al-Khalili. (Dec 2014)

"Believing what you know ain't so" ...

Knock Knock ...
 

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

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

Opt('MustDeclareVars', 1)

Example()

Func Example()
    Local $progressbar1, $progressbar2, $button, $wait, $s, $msg, $m
    
    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
EndFunc   ;==>Example

ho shiz, thanks.

I didn't expect you to post a code example.

;)

*edit*

same code from the helpfile.

Any original code?

Edited by Kalin

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

same code from the helpfile.

Yep. (So he/she knows about the help file. good.)

You did say Example, right?

Any original code?

Its original, just not mine.

My code need some context to work. ;)

---

(I see some others (with code) are passing by. So I'm shutting up for now.)

Edited by MvGulik

"Straight_and_Crooked_Thinking" : A "classic guide to ferreting out untruths, half-truths, and other distortions of facts in political and social discussions."
"The Secrets of Quantum Physics" : New and excellent 2 part documentary on Quantum Physics by Jim Al-Khalili. (Dec 2014)

"Believing what you know ain't so" ...

Knock Knock ...
 

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

Yep. (So he/she knows about the help file. good.)

You did say Example, right?

Its original, just not mine.

My code need some context to work. ;)

I know more about AutoIt than you think.

I just like to understand everything completely and clearly.

So nice try trying to act smooth.

;)

And the code isn't original if you're using it as an example.

:)

Edited by Kalin

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

Here's a little example I wrote up. It downloads the AutoItV3 setup EXE and displays the progress of the download.

#Include <GUIConstantsEx.Au3>
#Include <WindowsConstants.Au3>

Opt ('GUIOnEventMode', 1)

$GUI = GUICreate ('Progress Example', 200, 20)
GUISetOnEvent  ($GUI_EVENT_CLOSE, '_Exit')
$GUI_Progress = GUICtrlCreateProgress (0, 0, 200, 20, 0x01)
GUICtrlSetLimit ($GUI_Progress, 100)
$GUI_Percent = GUICtrlCreateLabel ('0%', 0, 2, 200, 20, 1)
GUICtrlSetColor ($GUI_Percent, '0xFFFFFF')
GUICtrlSetFont ($GUI_Percent, 10, 600)
GUICtrlSetBkColor ($GUI_Percent, $GUI_BKCOLOR_TRANSPARENT)
GUISetState (@SW_SHOW)

Sleep (2000)
$Msg = MsgBox (4, 'Start?','Click (Ok) to download AutoItV3 Setup.')
If $Msg = 7 Then Exit

$File_To_Download = 'http://www.autoitscript.com/cgi-bin/getfile.pl?autoit3/autoit-v3-setup.exe'
$Save_File_As = 'Setup.exe'
$Download = INetGet ($File_To_Download, $Save_File_As, 0, 1)
$File_Size = INetGetSize ($File_To_Download)

Do
    Sleep (15)
    _Update_Progress ()
Until INetGetInfo ($Download, 2) = True

Sleep (2000)
GUICtrlSetData ($GUI_Percent, 'Download Complete')

While 1
    Sleep (150)
WEnd

Func _Update_Progress ()
    $Progress = (INetGetInfo ($Download, 0) / $File_Size) * 100
    ConsoleWrite ($Progress & @CRLF)
    GUICtrlSetData ($GUI_Progress, $Progress)
    GUICtrlSetData ($GUI_Percent, Round ($Progress, 0) & '%')
EndFunc

Func _Exit ()
    Exit
EndFunc

Hope this helps! Enjoy~

- John

Edited by z0mgItsJohn

Latest Projects :- New & Improved TCP Chat

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

Galton box

GUICreate('Galton Box', 310, 480)
Dim $aProgessBars[10]

For $i = 0 To 9 Step +1
    $aProgessBars[$i] = GUICtrlCreateProgress($i*30+10, 10, 20, 460, 0x04)
Next

GUISetState()

For $iBall = 1 To 300 Step +1
    $iRow = 0
    For $iPin = 1 To 9 Step +1
        $iRow += Random(0, 1, 1)
    Next
    GUICtrlSetData($aProgessBars[$iRow], GUICtrlRead($aProgessBars[$iRow])+1)
    Sleep(15)
Next

Do
    Sleep(10)
Until GUIGetMsg() = -3
Edited by dwerf

Share this post


Link to post
Share on other sites

Kalin,

Like you I find Progress bars of limited value. The version I tend use the most is the Marquee style to show that something is happening while the script does something longish - like sorting through a lot of files when I have no idea how long it will take. It works like this:

#include <GUIConstantsEx.au3>
#include <ProgressConstants.au3>
#include <SendMessage.au3>

$hGUI = GUICreate("Test", 500, 500)
GUICtrlCreateProgress(10, 10, 400, 20, $PBS_MARQUEE)
_SendMessage(GUICtrlGetHandle(-1), $PBM_SETMARQUEE, True, 50) ; final parameter is update time in ms
GUISetState()

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd

I hope this offers you a suitable, if not original, example of where a Progress bar can come in handy. ;)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
My media player uses two different progress bars that you could look at for reference. One is used in the main GUI to track the progress of the song being played, and I use another when I build the music list, for that one I use the marquee style. That should give a couple of examples as to what you can use them for.

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

#14 ·  Posted (edited)

You guys are all awesome!

Such a perfect blend of knowledge and examples.

;)

*edit*

Why are progress bars commonly used when loading a windows form?

It loads automatic most of the time in AutoIt.

Edited by Kalin

Share this post


Link to post
Share on other sites

#15 ·  Posted (edited)

Here an example from the help:

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()

Or made by me:

;Fast hack by UEZ ;-)
#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

Opt("MustDeclareVars", 1)
Opt("GUIOnEventMode", 1)
Global $h = 150, $w = $h

Global $hGUI = GUICreate("GDI+ Circle Progress Meter by UEZ 2010", $w, $h, -1, -1, $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_TOPMOST))
Global $bg_color = 0xFFFFFF
GUISetBkColor($bg_color)
_WinAPI_SetLayeredWindowAttributes($hGUI, $bg_color, 0xFF)
GUISetState()

Circle_Progress_Init($hGUI, $w, $h, $bg_color)

GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")
GUIRegisterMsg($WM_NCHITTEST, "WM_NCHITTEST")

Global $fx, $progress
Global $angle = 0
Global $size = 111
Global $current = 0
Do
    $progress = $current / $size
    $angle = $progress * 360
    Circle_Progress($angle, $progress * 100)
    $current += 1
    Sleep(75)
Until $angle > 359

Sleep(500)
Circle_Progress(360, "Done", "%s")
Sleep(2500)
_Exit()

Func Circle_Progress_Init($hWnd, $Weight, $Height, $bg_color = 0xFFFFFF)
    _GDIPlus_Startup()
    Global $font = "Arial"
    Global $fsize = Floor($h / 10)
    Global $pen_size = Floor($Height / 6)
    Global $hPen = _GDIPlus_PenCreate(0, $pen_size)
    Global $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hWnd)
    Global $hBitmap = _GDIPlus_BitmapCreateFromGraphics($Weight, $Height, $hGraphics)
    Global $hBackbuffer = _GDIPlus_ImageGetGraphicsContext($hBitmap)
    _GDIPlus_GraphicsClear($hBackbuffer, "0xFF" & $bg_color)
    _GDIPlus_GraphicsSetSmoothingMode($hBackbuffer, 2)
EndFunc

Func Circle_Progress($angle, $text, $sFormat  = "%.2f", $fg_pencolor = 0xFF00FF00, $bg_pencolor = 0xFFD0FFD0, $clear_color = 0xFFFFFFFF)
    Local $ps2 = $pen_size / 2
    _GDIPlus_GraphicsClear($hBackbuffer, $clear_color)
    _GDIPlus_PenSetColor($hPen, $bg_pencolor)
    _GDIPlus_GraphicsDrawEllipse($hBackbuffer, $ps2, $ps2, $w - $pen_size, $h - $pen_size, $hPen)
    _GDIPlus_PenSetColor($hPen, $fg_pencolor)
    _GDIPlus_GraphicsDrawArc($hBackbuffer, $ps2, $ps2, $w - $pen_size, $h - $pen_size, -90, $angle, $hPen)
    $fx = StringLen(StringFormat($sFormat, $text)) * $fsize / 2.5
    _GDIPlus_GraphicsDrawString($hBackbuffer, StringFormat($sFormat, $text), $w / 2 - $fx, $h / 2 - $fsize * 0.75, $font, $fsize)
    _GDIPlus_GraphicsDrawImageRect($hGraphics, $hBitmap, 0, 0, $w, $h)
EndFunc

Func Circle_Progress_Close()
    _GDIPlus_PenDispose($hPen)
    _GDIPlus_BitmapDispose($hBitmap)
    _GDIPlus_GraphicsDispose($hBackbuffer)
    _GDIPlus_GraphicsDispose($hGraphics)
    _GDIPlus_Shutdown()
EndFunc

Func WM_NCHITTEST($hWnd, $iMsg, $iwParam, $ilParam)
    If ($hWnd = $hGui) And ($iMsg = $WM_NCHITTEST) Then Return $HTCAPTION
EndFunc ;==>WM_NCHITTEST

Func _Exit()
    Circle_Progress_Close()
    GUIDelete($hGUI)
    Exit
EndFunc

Br,

UEZ

Edited by UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
Share on other sites

Here an example from the help:

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()

Or made by me:

;Fast hack by UEZ ;-)
#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

Opt("MustDeclareVars", 1)
Opt("GUIOnEventMode", 1)
Global $h = 150, $w = $h

Global $hGUI = GUICreate("GDI+ Circle Progress Meter by UEZ 2010", $w, $h, -1, -1, $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_TOPMOST))
Global $bg_color = 0xFFFFFF
GUISetBkColor($bg_color)
_WinAPI_SetLayeredWindowAttributes($hGUI, $bg_color, 0xFF)
GUISetState()

Circle_Progress_Init($hGUI, $w, $h, $bg_color)

GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")
GUIRegisterMsg($WM_NCHITTEST, "WM_NCHITTEST")

Global $fx, $progress
Global $angle = 0
Global $size = 111
Global $current = 0
Do
    $progress = $current / $size
    $angle = $progress * 360
    Circle_Progress($angle, $progress * 100)
    $current += 1
    Sleep(75)
Until $angle > 359

Sleep(500)
Circle_Progress(360, "Done", "%s")
Sleep(2500)
_Exit()

Func Circle_Progress_Init($hWnd, $Weight, $Height, $bg_color = 0xFFFFFF)
    _GDIPlus_Startup()
    Global $font = "Arial"
    Global $fsize = Floor($h / 10)
    Global $pen_size = Floor($Height / 6)
    Global $hPen = _GDIPlus_PenCreate(0, $pen_size)
    Global $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hWnd)
    Global $hBitmap = _GDIPlus_BitmapCreateFromGraphics($Weight, $Height, $hGraphics)
    Global $hBackbuffer = _GDIPlus_ImageGetGraphicsContext($hBitmap)
    _GDIPlus_GraphicsClear($hBackbuffer, "0xFF" & $bg_color)
    _GDIPlus_GraphicsSetSmoothingMode($hBackbuffer, 2)
EndFunc

Func Circle_Progress($angle, $text, $sFormat  = "%.2f", $fg_pencolor = 0xFF00FF00, $bg_pencolor = 0xFFD0FFD0, $clear_color = 0xFFFFFFFF)
    Local $ps2 = $pen_size / 2
    _GDIPlus_GraphicsClear($hBackbuffer, $clear_color)
    _GDIPlus_PenSetColor($hPen, $bg_pencolor)
    _GDIPlus_GraphicsDrawEllipse($hBackbuffer, $ps2, $ps2, $w - $pen_size, $h - $pen_size, $hPen)
    _GDIPlus_PenSetColor($hPen, $fg_pencolor)
    _GDIPlus_GraphicsDrawArc($hBackbuffer, $ps2, $ps2, $w - $pen_size, $h - $pen_size, -90, $angle, $hPen)
    $fx = StringLen(StringFormat($sFormat, $text)) * $fsize / 2.5
    _GDIPlus_GraphicsDrawString($hBackbuffer, StringFormat($sFormat, $text), $w / 2 - $fx, $h / 2 - $fsize * 0.75, $font, $fsize)
    _GDIPlus_GraphicsDrawImageRect($hGraphics, $hBitmap, 0, 0, $w, $h)
EndFunc

Func Circle_Progress_Close()
    _GDIPlus_PenDispose($hPen)
    _GDIPlus_BitmapDispose($hBitmap)
    _GDIPlus_GraphicsDispose($hBackbuffer)
    _GDIPlus_GraphicsDispose($hGraphics)
    _GDIPlus_Shutdown()
EndFunc

Func WM_NCHITTEST($hWnd, $iMsg, $iwParam, $ilParam)
    If ($hWnd = $hGui) And ($iMsg = $WM_NCHITTEST) Then Return $HTCAPTION
EndFunc ;==>WM_NCHITTEST

Func _Exit()
    Circle_Progress_Close()
    GUIDelete($hGUI)
    Exit
EndFunc

Br,

UEZ

K, I will give you all an example of what I mean generally.

So we have a common windows GUI that when open loads a windows form.

Why would I need a progress bar to indicate this?

My answer would just to inform that user that it's loading.

But the problem is that autoit programs open quickly.

So If I was Interfacing with a website, and it loads automatically, why would I need a progress bar?

So many mysteries to this semi-helpful function.

;)

Share this post


Link to post
Share on other sites

I made a proggy called "MaXoFF" and it uses two progress bars. One is the Main "overall" progress for cleaners and the second progress is the individual cleaners. Each cleaner has a new progress bar. Only two appear at a time.

http://www.autoitscript.com/forum/index.php?showtopic=87144&view=findpost&p=625226

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

#18 ·  Posted (edited)

I made a proggy called "MaXoFF" and it uses two progress bars. One is the Main "overall" progress for cleaners and the second progress is the individual cleaners. Each cleaner has a new progress bar. Only two appear at a time.

http://www.autoitscript.com/forum/index.php?showtopic=87144&view=findpost&p=625226

8)

Oh thanks, this should answer some of my problems.

*cheers*

;)

Edited by Kalin

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