dynamicfor.blogg.se

Windows 10 monitor not turning off
Windows 10 monitor not turning off











In fact, I recall writing an Assembly version that was even simpler, circa 1998. Return SendMessage(GetDesktopWindow(), WM_SYSCOMMAND, SC_MONITORPOWER, 2) or return SendMessage(GetDesktopWindow(), WM_SYSCOMMAND, SC_SCREENSAVE, 0) If (LockWorkStation != NULL) (LockWorkStation)() PROC LockWorkStation = (PROC) GetProcAddress(hinstLib, "LockWorkStation")

windows 10 monitor not turning off

HINSTANCE hinstLib = LoadLibrary("user32")

windows 10 monitor not turning off

Int WINAPI WinMain(HINSTANCE hinstCurrent, HINSTANCE hinstPrevious, LPSTR lpszCmdLine, int nCmdShow) In fact I found my old C code, dated 2001, that does this plus locks the workstation from the command line: #define WIN 32_LEAN_AND_MEAN The shortcut can be assigned properties like a shortcut key (hotkey) too: Simply create a new shortcut (all entered in one line): powershell (Add-Type 'public static extern int PostMessage(int h,int m,int w,int l) ' -Name a -Pas)::PostMessage(-1,0x0112,0xF170,2) However, instead of SendMessage, use PostMessage, lest the script get stuck waiting for a reply. The method is based on the idea here - running a PowerShell script from the command line (to avoid PowerShell script security).

  • And set the state of the display in lParam to either 1 (lower power) or 2 (shut off) - though only the latter has ever worked for me.
  • Set wParam to 0xF170 (SC_MONITORPOWER).
  • It's so easy to trigger the monitor to sleep using the Win32 API WM_SYSCOMMAND:

    windows 10 monitor not turning off

    Hmmm, seems Windows has never improved, because I recall having this requirement back-in-the-day - haha, that was during my first project ever, when I was involved in some Win32 development. I wanted to turn off my monitor in Windows 10, while listening to music, rather than wait for the Power plan “Turn off the display” timer to kick in.













    Windows 10 monitor not turning off