I have a manually triggered AutoHotKey script that gradually lowers the volume of my laptop when (e.g.) ads are on in Spotify. Sadly, to get it working in Windows 7, it has to run as administrator, and thus requires a UAC prompt, which rather defeats the purpose.
However, this neat trick:Â Elevated Program Shortcut without UAC Prompt has sorted me out. (I had tried and failed to get the Application Compatibility Toolkit approach to work.)
Essentially, you create a non-scheduled task that runs as administrator which runs your program (here a compiled script) and then run that task, rather than the programme.
The AHK script is this (updated to use Vista Audio Control Functions; you need to have VA and Com in the same folder as the script):
master_volume := VA_GetMasterVolume()
min_volume_for_spotify := master_volume * 40 / 100
number_of_steps = 20
vol_step := (master_volume - min_volume_for_spotify) / number_of_steps
if master_volume < 10
MsgBox, Master volume is %master_volume% per cent: %master_volume% - %min_volume_for_spotify% is too low!
VA_SetMasterVolume(master_volume - (vol_step * A_Index))