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
}
- 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.
Gets the current position of a standard Windows progress bar.
Code: Select all
ControlGetProgress(Control, WinTitle = "", WinText = "") {
SendMessage 0x408,,, %Control%, %WinTitle%, %WinText%
return ErrorLevel
}
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%