lx-s / WinMute

WinMute lets you automatically mute your PC volume on certain events (e. g. Screensaver, Workstation Lock, Shutdown, etc.).
BSD 3-Clause "New" or "Revised" License
168 stars 6 forks source link

[REQ] Please mute the sound even when the monitor is manually turned off. #32

Closed splash70 closed 8 months ago

splash70 commented 9 months ago

This is a request, not a issue, so I'm sorry if it is not appropriate to write here...

Winmute works when Windows turns off the monitor, but not when the monitor is manually turned off. For example, with the HDMI connection, Windows can monitor the status of the monitor, so could you please make it work even if the monitor is manually turned off?

Thank you.

lx-s commented 9 months ago

Don’t worry - this is the place to request a feature :) I’ll look into it!

lx-s commented 8 months ago

Alright, unfortunately the apparently simple things aren't most of the time.

There is seemingly no way in the Windows API to get notified when a display is disconnected. For reference, see Is there any way to detect the monitor state in Windows (on or off)? on Stackoverflow.

The only thing I could implement would be a busy loop that checks every few seconds if the display is off (via GetDevicePowerState), but this goes against my rule, that I want to do everything by notification and not by waking the device every few seconds.

If I would do it via a busy check, then either: