Page 1 of 2

ProgressBar Examples

Posted: 23 Sep 2014, 07:59
by jNizM
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/

Re: ProgressBar Examples

Posted: 23 Sep 2014, 08:51
by joedf
Hmm didn't know about the marquee setting. Thanks ;)

Re: ProgressBar Examples

Posted: 23 Sep 2014, 10:19
by tmplinshi
I like the PBS_MARQUEE Progressbar. Thanks.

Windows XP looks like this:

Image

Re: ProgressBar Examples

Posted: 24 Sep 2014, 08:06
by jNizM
Image

Re: ProgressBar Examples

Posted: 24 Sep 2014, 11:46
by jballi
Looks useful. Thanks.

Re: ProgressBar Examples

Posted: 07 Dec 2014, 08:58
by jballi
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.

Re: ProgressBar Examples

Posted: 09 Dec 2014, 03:25
by ozzii
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' ?

Re: ProgressBar Examples

Posted: 09 Dec 2014, 08:56
by joedf
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)

Re: ProgressBar Examples

Posted: 10 Dec 2014, 04:56
by ozzii
@joedf
I saw this. Tried but can't change it to work with my script.
This is why I seek for some help ;)

Re: ProgressBar Examples

Posted: 10 Dec 2014, 09:37
by joedf
Post your code, that will help ;)

Re: ProgressBar Examples

Posted: 10 Dec 2014, 09:40
by jNizM
he did joedf ^^
http://ahkscript.org/boards/viewtopic.p ... 800#p31800

but you use Progress Command and not Gui, Add, Progress,

Re: ProgressBar Examples

Posted: 10 Dec 2014, 09:52
by joedf
Oh lol :facepalm: I got confused because I could not see the "GUI" command anywhere .. :P

Re: ProgressBar Examples

Posted: 17 Dec 2014, 08:03
by ozzii
So I must convert it into Gui then.
And also the CopyFileEx into User32.dll right ?

Re: ProgressBar Examples

Posted: 17 Dec 2014, 08:56
by jNizM
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.

Re: ProgressBar Examples

Posted: 19 Dec 2014, 07:27
by ozzii
thanks for the explanation, but still too much complicated for me.
I will stick with my previous command.
Thanks again.

Re: ProgressBar Examples

Posted: 19 Dec 2014, 09:48
by Peter2
jNizM wrote:Just a view ProgressBar Examples...
Code:
ProgressBar.ahk...
Thanks :clap: I will try it.

Re: ProgressBar Examples

Posted: 23 Jan 2017, 09:40
by kczx3
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.

Re: ProgressBar Examples

Posted: 30 Jan 2017, 04:56
by euras
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

Re: ProgressBar Examples

Posted: 03 Feb 2021, 03:47
by blackjoker
Very usefull, thanks!

Re: ProgressBar Examples

Posted: 03 Feb 2021, 06:01
by pallabibaruah18
Useful post. I will try and if i get issue will ask in the forum itself