Jump to content

How to create a Progress bar


oMBRa
 Share

Recommended Posts

How to create a progress bar like the one in the photo??

Here is a way to create a solid bar, but it doesn't have the label in front

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

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 633, 447, 193, 125)
$LastTheme = XPStyle(0)
$Progress1 = GUICtrlCreateProgress(144, 128, 150, 17, BitOR($PBS_SMOOTH,$WS_BORDER,$WS_CLIPSIBLINGS))
GUICtrlSetColor(-1,0x00ff00)
XPStyle($LastTheme)

GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
for $n = 0 to 100
    GUICtrlSetData($Progress1,$n)
    sleep(20)
Next

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

    EndSwitch
WEnd

Func XPStyle($theme = 0)
    If Not StringInStr(@OSTYPE, "WIN32_NT") Then Return 0
     
    If $theme = 0 Or Not IsArray($theme) Then
       $theme = DllCall("uxtheme.dll", "int", "GetThemeAppProperties")
        DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", 0)
        Return $theme
    ElseIf IsArray($theme) Then
        DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", $theme[0])
       ;$theme = ""
        Return $theme
    EndIf
    Return 0
EndFunc

Here is an example which uses a bitmap, and I expect it could be modified to put a label in front.

And here are some bitmaps

A1.bmpA2.bmpA3.bmp

Edited by martin
Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

Do I need those bitmap to make the script work correctly?? Because when I try to open those bitmap I get an error: the image cant be visualzied because has some error

If u are able to add a label it is perfect!

Edited by oMBra
Link to comment
Share on other sites

Do I need those bitmap to make the script work correctly?? Because when I try to open those bitmap I get an error: the image cant be visualzied because has some error

If u are able to add a label it is perfect!

To get the bitmaps you need to click on the links and then when the bitmap is shown right click over it and save as. The bitmaps need to be in a subfolder 'images'.

Here's another way which doesn't need any images.

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

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 633, 447, 193, 125)


$Label3 = GUICtrlCreateLabel("", 136, 172, 102, 17, BitOR($SS_CENTER,$SS_BLACKFRAME,$SS_CENTERIMAGE))
GUICtrlSetBkColor(-1,$GUI_BKCOLOR_TRANSPARENT )
$Label1 = GUICtrlCreateLabel("", 137, 173, 1, 15)
GUICtrlSetBkColor(-1, 0x00ff00)
$Label2 = GUICtrlCreateLabel("Label2", 136, 172, 102, 17, BitOR($SS_CENTER,$SS_CENTERIMAGE))
GUICtrlSetBkColor(-1,$GUI_BKCOLOR_TRANSPARENT )
GUISetState(@SW_SHOW)
for $n = 1 to 100
    controlmove($Form1,"",$Label1,137,173,$n,15)
    GUICtrlSetData($Label2,$n & "%")
    sleep(90)
Next

#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

    EndSwitch
WEnd
Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...