The power button on my second monitor is broken. I'm tired of manually unplugging the cable from the monitor. What do I want is to write a small app (Java, C#, or PowerShell script) that will turn the second monitor off and back on. I googled my problem and found a script that can put the monitor into sleep mode. But that's not exactly what I need.
Asked
Active
Viewed 691 times
0
-
Please show us what you already got and give as a name of your monitor, so we can help – Nicicalu Jun 09 '20 at 06:30
-
I think it would be pretty difficult. But I found a link that might help: https://www.powershellmagazine.com/2013/07/18/pstip-how-to-switch-off-display-with-powershell/ – Nicicalu Jun 09 '20 at 06:32
-
`[DllImport("user32.dll")] private static extern int SendMessage(int hWnd, int hMsg, int wParam, int lParam);` `SendMessage(0xFFFF, 0x112, 0xF170, (int)state);` – russianroadman Jun 09 '20 at 06:40
-
Do you understand this code? – Nicicalu Jun 09 '20 at 06:43
-
@Nicicalu I don't know what do you mean by monitor name, but it's LG monitor flatron l1752S – russianroadman Jun 09 '20 at 06:49
-
I couldn't figure what is first 3 params (SendMessage method) in code I gave – russianroadman Jun 09 '20 at 06:51
-
okay. it is a pretty hard task for a beginner. I wouldn't know how to do this either. Maybe you'll find some help in the internet or someone else comments here :/ – Nicicalu Jun 09 '20 at 07:03
-
Is your question a duplicate of https://stackoverflow.com/questions/713498/turn-on-off-monitor ? Please, see the answers to this question. My own opinion: Unfortunately, that doesn't seem to be a trivial task. I'm almost sure you won't get it resolved because everything related to the power is usually managed by the operating system. Hence, you would need to interfere with the operating system at a fairly low-level. But the SendMessage is an API provided by the operating system for similar things. – deralbert Jun 09 '20 at 10:22
2 Answers
0
There is the MultiMonitorTool by Nirsoft.
You can use it, or develop a program to work with.
Once I used Runtime.getRuntime().exec(...)
in Java
to get the job done.

D.Kastier
- 2,640
- 3
- 25
- 40
0
So the answer is that you can't turn off the power source for your monitor programmatically if the monitor has two cables - one for PC and another for power.

russianroadman
- 191
- 9
-
Yes, that sounds plausible. Just buy a socket with the On/Off button :) – deralbert Jun 09 '20 at 16:30