When SendMessage(HWND_BROADCAST, WM_SYSCOMMAND, WM_MONITORPOWER, 2) is issued, monitors power off, but when interactive action, and monitors come back on, is there a message sent?

Jibun no Kage 21 Reputation points
2022-06-30T17:59:54.913+00:00

When SendMessage(HWND_BROADCAST, WM_SYSCOMMAND, WM_MONITORPOWER, 2) is issued, monitors power off, but when interactive action, and monitors come back on, is there a message sent? There does not seem to be any event fired in the Application, Security or System log. Trying to find a way to hook when the monitors come back online, my application/script can respond to that situation.

If it is a matter of watching the system event queue? For mouse or keyboard input? An example of how to do that via, say powershell, or C# would be wonderful.

Any help greatly appreciated.

.NET
.NET
Microsoft Technologies based on the .NET software framework.
4,108 questions
Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,628 questions
0 comments No comments
{count} votes

Accepted answer
  1. Castorix31 86,986 Reputation points
    2022-06-30T19:16:04.473+00:00

    A way is to check the status of the monitor, in a Timer or a Thread
    On my OS (Windows 10 21H1), it works with NtPowerInformation, SystemVideoState and DEVICE_POWER_STATE
    When the monitor comes back on, I get PowerDeviceD0 (and PowerDeviceUnspecified when I set it off with WM_SYSCOMMAND and SC_MONITORPOWER (not WM_MONITORPOWER which does not exist...)


1 additional answer

Sort by: Most helpful
  1. Jibun no Kage 21 Reputation points
    2022-07-07T01:59:49.667+00:00

    Ah, I will give it a shot, thanks.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.