Windows introduced "Quiet Hours" OR "Do not disturb" feature from Windows version 8 onward. Using this feature, one can disable notifications popups for configured amount of time from task bar notification area.
I am trying to get current OS, Quiet hours within C++ or from C# application but haven't found any API or Event.
Can anybody help on this to resolve my issue?
Focus assist (also called quiet hours in earlier versions of Windows 10) allows you to avoid distracting notifications when you need to stay focused. It's set by default to activate automatically when you're duplicating your display, playing a game, or using an app in full screen mode.
Since a recent major update to Windows 10, "Quiet Hours" has changed to "Focus Assist" - and it seems to work differently, so previous answers don't apply any more.
The only solution I could find for this so far, is the one offered here.
There is a registry value set to 0 during quiet hours named "NOC_GLOBAL_SETTINGS_TOASTS_ENABLED". Here is working code to determine if a user currently has quiet hours enabled:
public static bool IsQuietHours()
{
string path = "HKEY_CURRENT_USER\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Notifications\\Settings";
string key = "NOC_GLOBAL_SETTING_TOASTS_ENABLED";
int? toastsEnabled = (int?)Microsoft.Win32.Registry.GetValue(path, key, 1);
return (toastsEnabled == 0);
}
It seems to me that the original answer from @PhilWilliams, albeit it being link only answer, was correct:
You can query the state by using SHQueryUserNotificationState()
function. See also QUERY_USER_NOTIFICATION_STATE
enumeration for possible value.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With