WinWaitProgress / ControlGetProgress

Post your working scripts, libraries and tools for AHK v1.1 and older
lexikos
Posts: 9690
Joined: 30 Sep 2013, 04:07
Contact:

WinWaitProgress / ControlGetProgress

02 Oct 2014, 23:29

WinWaitProgress
Waits for the progress bar on a window to reach (>=) a given value.

Code: Select all

WinWaitProgress(Progress = 100, WinTitle = "", WinText = "", Timeout = "") {
	began_at := A_TickCount
	While (n := ControlGetProgress("msctls_progress321", WinTitle, WinText)) != "FAIL"
		&& n < Progress && (Timeout = "" || (A_TickCount-began_at)/1000 < Timeout)
		Sleep 100
	return (ErrorLevel + 0) >= Progress
}
Notes:
  • Works with AutoHotkey v1.1 and probably v1.0. For v2.0, change = to := and FAIL to ERROR.
  • Returns immediately if the progress bar isn't found.
ControlGetProgress
Gets the current position of a standard Windows progress bar.

Code: Select all

ControlGetProgress(Control, WinTitle = "", WinText = "") {
	SendMessage 0x408,,, %Control%, %WinTitle%, %WinText%
	return ErrorLevel
}
Example
Wait for CCleaner to finish.

Code: Select all

if WinWaitProgress(100, "Piriform CCleaner")
	MsgBox Done cleaning.
else if (ErrorLevel = "FAIL")
	MsgBox Error
else
	MsgBox Timeout; progress=%ErrorLevel%
User avatar
joedf
Posts: 9000
Joined: 29 Sep 2013, 17:08
Location: Canada
Contact:

Re: WinWaitProgress / ControlGetProgress

03 Oct 2014, 02:23

Very Nice! :)
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]
canisdibellum
Posts: 47
Joined: 09 Oct 2014, 11:44

Re: WinWaitProgress / ControlGetProgress

12 Jul 2016, 02:57

I like the idea! Any way to use something similar to monitor windows automatic driver installer (pnp) window to watch for no more spimmimg circle icons?

Return to “Scripts and Functions (v1)”

Who is online

Users browsing this forum: Bing [Bot] and 221 guests