[python-win32] turning monitors off from Python?

Alec Bennett whatyoulookin at yahoo.com
Thu Dec 4 12:17:40 CET 2008


Eureka! In case anyone else comes down this path, the trick is to use HWND_BROADCAST to send the message to all windows. So the code to turn off all monitors:

SC_MONITORPOWER = 0xF170
win32gui.SendMessage(win32con.HWND_BROADCAST, win32con.WM_SYSCOMMAND, SC_MONITORPOWER, 2)

According to the documentation, that last parameter (the 2) could be a 1 for low power (not sure if any Windows computers support this?), or a -1 to turn the monitor back on.

Of course you can always turn the monitor back on by moving the mouse or hitting a key.






      


More information about the python-win32 mailing list