Skip to content

Instantly share code, notes, and snippets.

@EugeneLoy
Last active November 29, 2023 08:50
  • Star 67 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
powershell (Add-Type '[DllImport(\"user32.dll\")]^public static extern int PostMessage(int hWnd, int hMsg, int wParam, int lParam);' -Name a -Pas)::PostMessage(-1,0x0112,0xF170,2)
@Ma-XX-oN
Copy link

This shuts off the screen and locks the desktop. Would be nice if there was a way to just shutoff the screen.

AFAIK, the Windows OS will wake the screen on any KB or mouse event, and will bring you to the unlock screen (or desktop if security is disabled).

@Shazib
Copy link

Shazib commented Apr 10, 2023

Is this still working for you guys? for me the screen turns off then immediatley turns back on - no mouse or keyboard movements (by me)...

@EugeneLoy
Copy link
Author

@Shazib
Can confirm that it works for me with Windows 10 Pro 22H2.

@alexeyrv
Copy link

alexeyrv commented Jun 2, 2023

First of all thanks to EugeneLoy and unknown for me the author of the command :-)
Today 2.6.2023 - it works for me. Conditions - Win10 22H2. Two monitors. Both displays are turned off one time.

Is this still working for you guys? for me the screen turns off then immediatley turns back on - no mouse or keyboard movements (by me)...

Cheers.

@Shazib
Copy link

Shazib commented Jun 3, 2023

FYI I've discovered that this doesn't play nice with my monitor that supports DDC/CI control. https://github.com/xanderfrangos/twinkle-tray/ works though.

@GustavoCOD4
Copy link

Thank you

@Nine-Iron
Copy link

To anyone looking to shut off a specific monitor and have it stay off until you physically push the monitor power button, it looks like there is a utility for it. Can even change settings by command line.

https://www.winhelponline.com/blog/turn-off-monitor-shortcut-command-windows/

Nirsoft’s ControlMyMonitor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment