-
Notifications
You must be signed in to change notification settings - Fork 72
/
Copy pathSetTaskbarProcess.ahk
38 lines (34 loc) · 1.11 KB
/
SetTaskbarProcess.ahk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
; Link:
; Author:
; Date:
; for: AHK_L
/*
*/
; SetTaskbarProgress - Windows 7+
; by lexikos, modified by gwarble for U64,U32,A32 compatibility
;
; pct - A number between 0 and 100 or a state value (see below).
; state - "N" (normal), "P" (paused), "E" (error) or "I" (indeterminate).
; If omitted (and pct is a number), the state is not changed.
; hwnd - The hWnd of the window which owns the taskbar button.
; If omitted, the Last Found Window is used.
;
SetTaskbarProgress(pct, state="", hwnd="") {
static tbl, s0:=0, sI:=1, sN:=2, sE:=4, sP:=8
if !tbl
Try tbl := ComObjCreate("{56FDF344-FD6D-11d0-958A-006097C9A090}"
, "{ea1afb91-9e28-4b86-90e9-9e9f8a5eefaf}")
Catch
Return 0
If hwnd =
hwnd := WinExist()
If pct is not number
state := pct, pct := ""
Else If (pct = 0 && state="")
state := 0, pct := ""
If state in 0,I,N,E,P
DllCall(NumGet(NumGet(tbl+0)+10*A_PtrSize), "uint", tbl, "uint", hwnd, "uint", s%state%)
If pct !=
DllCall(NumGet(NumGet(tbl+0)+9*A_PtrSize), "uint", tbl, "uint", hwnd, "int64", pct*10, "int64", 1000)
Return 1
}