Is it possible to put a single monitor to sleep using WinAPI/C#?
Asked Answered
S

2

9

By using the Windows API it is possible to put the monitors into sleep mode:

[DllImport("user32.dll")]
static extern IntPtr SendMessage(IntPtr hWnd, uint Msg, IntPtr wParam, IntPtr lParam);

and then

SendMessage(this.Handle, WM_SYSCOMMAND, (IntPtr)SC_MONITORPOWER, (IntPtr)2);

When running the command above, both monitors go to sleep. Is it possible to make this affect only one of multiple connected monitors?

Shipboard answered 14/12, 2010 at 19:45 Comment(0)
R
2

Exactly I don't know if you can put into sleep a specific monitor.. but you can achieve this by changing number of displays to One (assuming you have 2), which you want to be awake. The other one will automatically goes to sleep after about a minute (most monitors enter power save mode after about a minute after disconnect). You are essentially disconnecting the monitor, programatically. You can activate it when you need it.

However this method will have other implications, which you will know once you start playing with it.

Reeducate answered 20/12, 2010 at 2:54 Comment(3)
Like windows on the second monitor being moved :)Scutch
@Erlend: If you have achieved this.. can you post on how you made it possible.. I currently is looking for similar solution.. And while I have suggested an approach.. trying to find how you got it worked.. if at all..Reeducate
Unfortunately, I could not achieve this.Shipboard
I
2

According to this...no.

The reason being is that the API is turning off the display which is defined as both monitors. Turning off a specific monitor would be a hardware tie in.

Iz answered 14/12, 2010 at 19:53 Comment(0)
R
2

Exactly I don't know if you can put into sleep a specific monitor.. but you can achieve this by changing number of displays to One (assuming you have 2), which you want to be awake. The other one will automatically goes to sleep after about a minute (most monitors enter power save mode after about a minute after disconnect). You are essentially disconnecting the monitor, programatically. You can activate it when you need it.

However this method will have other implications, which you will know once you start playing with it.

Reeducate answered 20/12, 2010 at 2:54 Comment(3)
Like windows on the second monitor being moved :)Scutch
@Erlend: If you have achieved this.. can you post on how you made it possible.. I currently is looking for similar solution.. And while I have suggested an approach.. trying to find how you got it worked.. if at all..Reeducate
Unfortunately, I could not achieve this.Shipboard

© 2022 - 2024 — McMap. All rights reserved.