Here is a Windows PowerShell script that I researched several years ago - I got some help from folks on a forum - I don't remember which one.
Incidentally, the main reason I use it is to reset my graphics card. I use 4 screens and for some reason my primary screen occasionally reverts to low res and I can not get to the reboot button. I found that when the monitor wakes up it restores to the proper res.
Copy the text below into a file name like monitor_off.ps1. If you edit your file associations, you can execute it by double clicking the file. Or as pointed out by "Davidw" below, right click and select run with Powershell.
# Windows PowerShell - Turn display off by calling WindowsAPI.
# Jan Zumwalt - rev 2017.12.05
# Moving the mouse or pressing a keyboard key reactivates the screen.
# works with multi-screen systems too.
# SendMessage(HWND_BROADCAST,WM_SYSCOMMAND, SC_MONITORPOWER, POWER_OFF)
# HWND_BROADCAST 0xffff
# WM_SYSCOMMAND 0x0112
# SC_MONITORPOWER 0xf170
# POWER_OFF 0x0002
Add-Type -TypeDefinition '
using System;
using System.Runtime.InteropServices;
namespace Utilities {
public static class Display
{
[DllImport("user32.dll", CharSet = CharSet.Auto)]
private static extern IntPtr SendMessage(
IntPtr hWnd,
UInt32 Msg,
IntPtr wParam,
IntPtr lParam
);
public static void PowerOff ()
{
SendMessage(
(IntPtr)0xffff, // HWND_BROADCAST
0x0112, // WM_SYSCOMMAND
(IntPtr)0xf170, // SC_MONITORPOWER
(IntPtr)0x0002 // POWER_OFF
);
}
}
}
'
[Utilities.Display]::PowerOff()
Comments are not for extended discussion; this conversation has been moved to chat.
– DavidPostill – 2017-12-05T06:16:11.1801Why can't you let your OS put the monitor to sleep? Does the program not work if the monitor is asleep? – Salman A – 2017-12-05T08:57:18.670
7That program of your smells like a bot or a cheat for something... Hm... – T. Sar – 2017-12-05T10:52:37.877
1@T.Sar Well for me, that program is commonly Sony Vegas taking half a day to render a video. – IllidanS4 wants Monica back – 2017-12-05T14:03:21.880
@IllidanS4 Why would you need to keep the mouse moving to use Sony Vegas? – T. Sar – 2017-12-05T14:09:07.320
@T.Sar Ah, I didn't notice that note. For Vegas, not moving the mouse is surely better. As for the mouse, I think that there are programs for Ultima Online designed to increase your stats by training overnight, and these aren't considered cheats on some servers. – IllidanS4 wants Monica back – 2017-12-05T14:16:56.333
5Super lo-fi solution: throw a thick towel / blanket on your monitor – LocustHorde – 2017-12-05T14:24:44.783
I'd like to know what model number, purchase date and the circumstances behind the broken power button because HP Z Display monitors all have 3 year limited warranties. Also, are we talking about a desktop or laptop? I imagine desktop but a laptop you can change the power/sleep button settings to turn off monitor. – Larry B – 2017-12-05T14:50:21.860
7change the input source to something else, wait for monitor to sleep. – Will – 2017-12-05T19:13:37.817
2My comment got caught up with the others that got moved to chat, so sorry if you replied and I missed it. @Vahn what is your objection to unplugging the power or video cord for the monitor? Is it hard to reach? Are you worried about damage? Does your software require a connected and powered monitor to run? – Kat – 2017-12-05T22:41:28.080
@@LocustHorde. I do not want to cover my monitor. @@Kat. That time the monitor and computer share the same power source and it's hard to reach. If I plug in and out the monitor only daily it's quite annoying. Usually I press switch in the power source to turn on my monitor and my PC. – Vahn – 2017-12-06T01:28:17.413