I think it can be relatively easily done with Autohotkey.
With task scheduler, add task with Program: C:\path\to\autohotkey.exe
Parameters: "C:\...path\to\script.ahk"
to run on idle under your account (only when user is logged in, uncheck [ ]
Stop if computer ceases to be idle, the script will unmute and exit on its own):
script.ahk
:
#NoEnv
SoundGet manually_muted,,MUTE
If (manually_muted = "Off") {
currently_idle := A_TimeIdle
SoundSet 1,,MUTE
Loop
{
Sleep 1000
} Until (A_TimeIdle < currently_idle)
SoundSet 0,,MUTE
}
ExitApp
Without task scheduler, use following script (just run it, it will stay resident using about 4 MB of RAM):
#NoEnv
#NoTrayIcon
#Persistent
#SingleInstance force
TimeIdleToMute_ms := 15 * 60 * 1000 ; timeout in milliseconds
SetTimer MuteUntilIdleEnds, % TimeIdleToMute_ms
Exit
MuteUntilIdleEnds() {
global TimeIdleToMute_ms
static idlemuted := 0
If (!idlemuted && A_TimeIdle > TimeIdleToMute_ms) {
SoundGet manually_muted,,MUTE
If (manually_muted = "Off") {
idlemuted := A_TimeIdle
SoundSet 1,,MUTE
Loop
{
Sleep 1000 ; ms
} Until (A_TimeIdle < idlemuted)
SoundSet 0,,MUTE
idlemuted := 0
}
}
}
Both scripts might be rewritten to react to Windows messages instead of idle-looping, but even now resource consumption is negligible.
Second script, when running without administrator privileges, might have trouble detecting activity of apps running with administrator privileges (it will mute after timeout when they are focused despite user has activity with them). However if you'll occasionally switch focus to non-admin programs until the timeout hits, it will suffice to reset the timer. Also, switching to non-admin program will end the mute, since script will detect activity.
Both scripts are written and quickly tested for the answer, there might be bugs, report and beware :)
P. S. SE, where the syntax highlighting!?