using System.Runtime.InteropServices; using PInvoke; using static PInvoke.Shell32; namespace hass_desktop_service.StateDetectors.Windows.Fullscreen { public enum UserNotificationState { /// /// A screen saver is displayed, the machine is locked, /// or a nonactive Fast User Switching session is in progress. /// NotPresent = 1, /// /// A full-screen application is running or Presentation Settings are applied. /// Presentation Settings allow a user to put their machine into a state fit /// for an uninterrupted presentation, such as a set of PowerPoint slides, with a single click. /// Busy = 2, /// /// A full-screen (exclusive mode) Direct3D application is running. /// RunningDirect3dFullScreen = 3, /// /// The user has activated Windows presentation settings to block notifications and pop-up messages. /// PresentationMode = 4, /// /// None of the other states are found, notifications can be freely sent. /// AcceptsNotifications = 5, /// /// Introduced in Windows 7. The current user is in "quiet time", which is the first hour after /// a new user logs into his or her account for the first time. During this time, most notifications /// should not be sent or shown. This lets a user become accustomed to a new computer system /// without those distractions. /// Quiet time also occurs for each user after an operating system upgrade or clean installation. /// QuietTime = 6 }; public class UserNotificationStateDetector { [DllImport("shell32.dll")] static extern int SHQueryUserNotificationState(out UserNotificationState state); public UserNotificationState GetState(){ UserNotificationState state; SHQueryUserNotificationState(out state); return state; } } }