Thanks for the message codes. I put together a function that takes the name of the app, the desired vol. level, and sets the relevant volume slider. Identifying the slider by app name is a bit hacky. It relies on the hor. distance from the text label control. This may need tweaking for your DPI/font settings, but it works for me.
Code:
SetTitleMatchMode 2
; Name of the app you want to control
appName = System Sounds
; Volume level you want
newVal = 50 ; 0-100
Run sndvol ; launch Win sound mixer
WinWait Volume Mixer
SetVal(appName, newVal)
WinClose Volume Mixer ; close the mixer
SetVal(appName, newVal) {
; the slider IDs seem to start at 321
startIDX = 321
; the app slider is identified by hor. distance from its text label
; maxDiff below sets the maximum allowed distance
; On my system, with my DPI and fonts, the reported distance is 36
maxDiff = 40
ControlGetPos, refX, , , , % appName, Volume Mixer
x = 1
while ( x != "") {
tbIDX := startIDX + A_Index - 1
ControlGetPos, x, , , , msctls_trackbar%tbIDX%, Volume Mixer
diff := Abs(x-refX)
if (diff < maxDiff && diff != "")
{
; msgbox diff: %diff% refX: %refX% tbIDX: %tbIDX% x: %x%
; SendMessage TBM_GETPOS:=0x400,,, msctls_trackbar%tbIDX%, Volume Mixer
v := 100 - newVal ; Note range is 0-100, but reversed.
SendMessage TBM_SETPOSNOTIFY:=0x422, 1, v, msctls_trackbar%tbIDX%, Volume Mixer
break
}
}
}