ProgressBar Examples

Helpful script writing tricks and HowTo's
User avatar
jNizM
Posts: 3183
Joined: 30 Sep 2013, 01:33
Contact:

ProgressBar Examples

23 Sep 2014, 07:59

Just a view ProgressBar Examples

Screenshot:
Image

Code:

Code: Select all

; GLOBAL SETTINGS ===============================================================================================================

#Warn
#NoEnv
#SingleInstance Force

global WM_USER               := 0x00000400
global PBM_SETMARQUEE        := WM_USER + 10
global PBM_SETSTATE          := WM_USER + 16
global PBS_MARQUEE           := 0x00000008
global PBS_SMOOTH            := 0x00000001
global PBS_VERTICAL          := 0x00000004
global PBST_NORMAL           := 0x00000001
global PBST_ERROR            := 0x00000002
global PBST_PAUSE            := 0x00000003
global STAP_ALLOW_NONCLIENT  := 0x00000001
global STAP_ALLOW_CONTROLS   := 0x00000002
global STAP_ALLOW_WEBCONTENT := 0x00000004
global WM_THEMECHANGED       := 0x0000031A

; SCRIPT ========================================================================================================================

Gui, Margin, 5, 5
Gui, Font, s14 Bold
Gui, Add, Text, xm ym 0x200, Progressbar Examples

; ------------------------------------------------------------------------------------------------------
Gui, Add, Progress, w300 h20, 50

; ------------------------------------------------------------------------------------------------------
Gui, Add, Progress, w300 h20 hwndMARQ1 +%PBS_MARQUEE%, 50
DllCall("User32.dll\SendMessage", "Ptr", MARQ1, "Int", PBM_SETMARQUEE, "Ptr", 1, "Ptr", 50)

; ------------------------------------------------------------------------------------------------------
Gui, Add, Progress, w300 h20 BackgroundC9C9C9, 50

; ------------------------------------------------------------------------------------------------------
Gui, Add, Progress, w300 h20 BackgroundC9C9C9 hwndMARQ2 +%PBS_MARQUEE%, 50
DllCall("User32.dll\SendMessage", "Ptr", MARQ2, "Int", PBM_SETMARQUEE, "Ptr", 1, "Ptr", 50)

; ------------------------------------------------------------------------------------------------------
DllCall("uxtheme.dll\SetThemeAppProperties", "UInt", 0)
Gui, Add, Progress, w300 h20 c66EE66 hwndUTHEME, 50
;DllCall("User32.dll\SendMessage", "Ptr", UTHEME, "Int", WM_THEMECHANGED, "Ptr", 0, "Ptr", 0)
DllCall("uxtheme.dll\SetThemeAppProperties", "UInt", 7)

; ------------------------------------------------------------------------------------------------------
DllCall("uxtheme.dll\SetThemeAppProperties", "UInt", 0)
Gui, Add, Progress, w300 h20 c66EE66 hwndMARQ3 +%PBS_MARQUEE%, 50
DllCall("User32.dll\SendMessage", "Ptr", MARQ3, "Int", PBM_SETMARQUEE, "Ptr", 1, "Ptr", 50)
DllCall("uxtheme.dll\SetThemeAppProperties", "UInt", 7)

; ------------------------------------------------------------------------------------------------------
Gui, Add, Progress, w300 h20 -%PBS_SMOOTH%, 50

; ------------------------------------------------------------------------------------------------------
Gui, Add, Progress, w300 h20 hwndMARQ4 -%PBS_SMOOTH% +%PBS_MARQUEE%, 50
DllCall("User32.dll\SendMessage", "Ptr", MARQ4, "Int", PBM_SETMARQUEE, "Ptr", 1, "Ptr", 50)

; ------------------------------------------------------------------------------------------------------
Gui, Add, Progress, w300 h20 hwndPROG -%PBS_SMOOTH%, 50
DllCall("User32.dll\SendMessage", "Ptr", PROG, "Int", PBM_SETSTATE, "Ptr", PBST_NORMAL, "Ptr", 0)

; ------------------------------------------------------------------------------------------------------
Gui, Add, Progress, w300 h20 hwndPROR -%PBS_SMOOTH%, 50
DllCall("User32.dll\SendMessage", "Ptr", PROR, "Int", PBM_SETSTATE, "Ptr", PBST_ERROR, "Ptr", 0)

; ------------------------------------------------------------------------------------------------------
Gui, Add, Progress, w300 h20 hwndPROY -%PBS_SMOOTH%, 50
DllCall("User32.dll\SendMessage", "Ptr", PROY, "Int", PBM_SETSTATE, "Ptr", PBST_PAUSE, "Ptr", 0)

; ------------------------------------------------------------------------------------------------------

Gui, Show, AutoSize
return

; EXIT ==========================================================================================================================

Close:
GuiClose:
GuiEscape:
    exitapp
More:
- ASCII Progress Bar ==> Old Forum /board/topic/90674-ascii-progress-bar/
[AHK] v2.0.5 | [WIN] 11 Pro (Version 22H2) | [GitHub] Profile
User avatar
joedf
Posts: 8940
Joined: 29 Sep 2013, 17:08
Location: Canada
Contact:

Re: ProgressBar Examples

23 Sep 2014, 08:51

Hmm didn't know about the marquee setting. Thanks ;)
Image Image Image Image Image
Windows 10 x64 Professional, Intel i5-8500, NVIDIA GTX 1060 6GB, 2x16GB Kingston FURY Beast - DDR4 3200 MHz | [About Me] | [About the AHK Foundation] | [Courses on AutoHotkey]
[ASPDM - StdLib Distribution] | [Qonsole - Quake-like console emulator] | [LibCon - Autohotkey Console Library]
tmplinshi
Posts: 1604
Joined: 01 Oct 2013, 14:57

Re: ProgressBar Examples

23 Sep 2014, 10:19

I like the PBS_MARQUEE Progressbar. Thanks.

Windows XP looks like this:

Image
User avatar
jNizM
Posts: 3183
Joined: 30 Sep 2013, 01:33
Contact:

Re: ProgressBar Examples

24 Sep 2014, 08:06

Image
[AHK] v2.0.5 | [WIN] 11 Pro (Version 22H2) | [GitHub] Profile
User avatar
jballi
Posts: 723
Joined: 29 Sep 2013, 17:34

Re: ProgressBar Examples

24 Sep 2014, 11:46

Looks useful. Thanks.
User avatar
jballi
Posts: 723
Joined: 29 Sep 2013, 17:34

Re: ProgressBar Examples

07 Dec 2014, 08:58

Windows 7.

Assume PBS_SMOOTH style has been removed.

Ran into a weird problem. If I change the state of the progress bar from normal, i.e. PBST_NORMAL, to pause, i.e. PBST_PAUSE, it works most of the time. I would guess 85+%. However, the progress bar for the PBST_NORMAL state is also an animation and so if the bar is somewhere in it's animation, the request to change the state to PBST_PAUSE many times fails. I've resorted to calling the PBM_SETSTATE message twice (with a short sleep in between) and it does fix the problems some of the time but not all of the time.

I know this is not the help forum but this topic hits right on the situation so I'm posting it here. Does anyone have any ideas on the correct way to change the state from normal to pause and have it succeed 100% of the time? Thanks.



Edit: 20141207

This appears to be a Windows 7 bug. Microsoft is ignoring it (for now).

I found one workaround from Jim Barry on a Microsoft Windows forum which seems to do the trick. It appears that the progress bar only animates when moving forward so changing the position of the progress bar to the current position + 1 and then changing it back before changing the state fixes the problem. You can find the full post here.
ozzii
Posts: 481
Joined: 30 Oct 2013, 06:04

Re: ProgressBar Examples

09 Dec 2014, 03:25

Question:
I have this

Code: Select all

address := registercallback("update")

update(var1lo,var1hi,var2lo,var2hi,var3lo,var3hi,var4lo,var4hi,var5,var6,var7,var8,var9)
{
	If (A_PtrSize = 8)
        copied := (var1hi / var1lo) * 100
    Else
        copied := (var2lo/var1lo) * 100
    progress, % copied,,Transfert du fichier !,Copie
    return 0
}

dllcall("CopyFileEx",str,FicNAS1,str,FicLocal1,Uint,address,Uint,0,int,0,int,0)
progress, off
Can you help me to 'convert' to 'marquee' ?
User avatar
joedf
Posts: 8940
Joined: 29 Sep 2013, 17:08
Location: Canada
Contact:

Re: ProgressBar Examples

09 Dec 2014, 08:56

From the example script

Code: Select all

global WM_USER               := 0x00000400
global PBM_SETMARQUEE        := WM_USER + 10
global PBS_MARQUEE           := 0x00000008
global PBS_SMOOTH            := 0x00000001

;Flat marquee
Gui, Add, Progress, w300 h20 hwndMARQ1 +%PBS_MARQUEE%, 50
DllCall("User32.dll\SendMessage", "Ptr", MARQ1, "Int", PBM_SETMARQUEE, "Ptr", 1, "Ptr", 50)

;Smooth marquee
Gui, Add, Progress, w300 h20 hwndMARQ4 -%PBS_SMOOTH% +%PBS_MARQUEE%, 50
DllCall("User32.dll\SendMessage", "Ptr", MARQ4, "Int", PBM_SETMARQUEE, "Ptr", 1, "Ptr", 50)
Image Image Image Image Image
Windows 10 x64 Professional, Intel i5-8500, NVIDIA GTX 1060 6GB, 2x16GB Kingston FURY Beast - DDR4 3200 MHz | [About Me] | [About the AHK Foundation] | [Courses on AutoHotkey]
[ASPDM - StdLib Distribution] | [Qonsole - Quake-like console emulator] | [LibCon - Autohotkey Console Library]
ozzii
Posts: 481
Joined: 30 Oct 2013, 06:04

Re: ProgressBar Examples

10 Dec 2014, 04:56

@joedf
I saw this. Tried but can't change it to work with my script.
This is why I seek for some help ;)
User avatar
joedf
Posts: 8940
Joined: 29 Sep 2013, 17:08
Location: Canada
Contact:

Re: ProgressBar Examples

10 Dec 2014, 09:37

Post your code, that will help ;)
Image Image Image Image Image
Windows 10 x64 Professional, Intel i5-8500, NVIDIA GTX 1060 6GB, 2x16GB Kingston FURY Beast - DDR4 3200 MHz | [About Me] | [About the AHK Foundation] | [Courses on AutoHotkey]
[ASPDM - StdLib Distribution] | [Qonsole - Quake-like console emulator] | [LibCon - Autohotkey Console Library]
User avatar
jNizM
Posts: 3183
Joined: 30 Sep 2013, 01:33
Contact:

Re: ProgressBar Examples

10 Dec 2014, 09:40

he did joedf ^^
http://ahkscript.org/boards/viewtopic.p ... 800#p31800

but you use Progress Command and not Gui, Add, Progress,
[AHK] v2.0.5 | [WIN] 11 Pro (Version 22H2) | [GitHub] Profile
User avatar
joedf
Posts: 8940
Joined: 29 Sep 2013, 17:08
Location: Canada
Contact:

Re: ProgressBar Examples

10 Dec 2014, 09:52

Oh lol :facepalm: I got confused because I could not see the "GUI" command anywhere .. :P
Image Image Image Image Image
Windows 10 x64 Professional, Intel i5-8500, NVIDIA GTX 1060 6GB, 2x16GB Kingston FURY Beast - DDR4 3200 MHz | [About Me] | [About the AHK Foundation] | [Courses on AutoHotkey]
[ASPDM - StdLib Distribution] | [Qonsole - Quake-like console emulator] | [LibCon - Autohotkey Console Library]
ozzii
Posts: 481
Joined: 30 Oct 2013, 06:04

Re: ProgressBar Examples

17 Dec 2014, 08:03

So I must convert it into Gui then.
And also the CopyFileEx into User32.dll right ?
User avatar
jNizM
Posts: 3183
Joined: 30 Sep 2013, 01:33
Contact:

Re: ProgressBar Examples

17 Dec 2014, 08:56

1. CopyFileEx is in Kernel32.dll (see here: CopyFileEx function)

2. From HelpFile: DllCall (Parameters)
DllFile may be omitted when calling a function that resides in User32.dll, Kernel32.dll, ComCtl32.dll, or Gdi32.dll. For example, "User32\IsWindowVisible" produces the same result as "IsWindowVisible".

Personally, I prefer the DllName, to know in which dll my function is stored.
[AHK] v2.0.5 | [WIN] 11 Pro (Version 22H2) | [GitHub] Profile
ozzii
Posts: 481
Joined: 30 Oct 2013, 06:04

Re: ProgressBar Examples

19 Dec 2014, 07:27

thanks for the explanation, but still too much complicated for me.
I will stick with my previous command.
Thanks again.
Peter2
Posts: 325
Joined: 21 Sep 2014, 14:38
Location: CH

Re: ProgressBar Examples

19 Dec 2014, 09:48

jNizM wrote:Just a view ProgressBar Examples...
Code:
ProgressBar.ahk...
Thanks :clap: I will try it.
Peter (AHK Beginner) / Win 10 x64, AHK Version v1.1.33
User avatar
kczx3
Posts: 1640
Joined: 06 Oct 2015, 21:39

Re: ProgressBar Examples

23 Jan 2017, 09:40

I'm trying to use a marquee progressbar and am finding that the animation is not smooth due to the operations that occur after that point in my script. Seems like it's a problem to due the single threaded nature of AHK but I'm not sure. The code that occurs after I set the progressbar to marquee is a file loop where i open xlsx files, save as CSV, then open the CSV with an ADODB.Stream object to save as utf-8 since excel saves CSVs as ASCII.
euras
Posts: 429
Joined: 05 Nov 2015, 12:56

Re: ProgressBar Examples

30 Jan 2017, 04:56

How to do that Progressbar will work smoothly?
Like I click Submit button, some commands goes and progressbar goes smoothly too? Now it goes as a brick :/

Code: Select all

global WM_USER               := 0x00000400
global PBM_SETMARQUEE        := WM_USER + 10
global PBM_SETSTATE          := WM_USER + 16
global PBS_MARQUEE           := 0x00000008
global PBS_SMOOTH            := 0x00000001
global PBS_VERTICAL          := 0x00000004
global PBST_NORMAL           := 0x00000001
global PBST_ERROR            := 0x00000002
global PBST_PAUSE            := 0x00000003
global STAP_ALLOW_NONCLIENT  := 0x00000001
global STAP_ALLOW_CONTROLS   := 0x00000002
global STAP_ALLOW_WEBCONTENT := 0x00000004
global WM_THEMECHANGED       := 0x0000031A

F11::
Gui, Add, Progress, w300 h20 hwndPROG -%PBS_SMOOTH%, 100
DllCall("User32.dll\SendMessage", "Ptr", PROG, "Int", PBM_SETSTATE, "Ptr", PBST_NORMAL, "Ptr", 0)
Gui, Show, AutoSize
SetTitleMatchMode, 2
WinActivate, Notepad
WinWaitActive, Notepad
Sleep 500
Send, 12345
Sleep 500
Send {Tab}
Send, some extra text
Sleep 500
Send {Enter}
Gui, Destroy
return
User avatar
blackjoker
Posts: 18
Joined: 01 Dec 2020, 02:57

Re: ProgressBar Examples

03 Feb 2021, 03:47

Very usefull, thanks!
pallabibaruah18
Posts: 14
Joined: 20 Jan 2021, 23:20

Re: ProgressBar Examples

03 Feb 2021, 06:01

Useful post. I will try and if i get issue will ask in the forum itself

Return to “Tutorials (v1)”

Who is online

Users browsing this forum: No registered users and 44 guests