Last active
July 15, 2022 09:44
-
-
Save x011/dc1fcdd11fb2ac157865e1e7cf2caeba to your computer and use it in GitHub Desktop.
Pyhon script to turn the monitor On/Off on windows systems.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import win32gui, win32con | |
from time import sleep | |
SC_MONITORPOWER = 0xF170 | |
win32gui.SendMessage(win32con.HWND_BROADCAST, win32con.WM_SYSCOMMAND, SC_MONITORPOWER, 2) # Off | |
sleep(2) | |
win32gui.SendMessage(win32con.HWND_BROADCAST, win32con.WM_SYSCOMMAND, SC_MONITORPOWER, -1) # On | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment