waking a sleeping monitor with python?

A forum for general discussion of the Python programming language.

waking a sleeping monitor with python?

Postby darter » Wed Mar 06, 2013 6:22 am

Would anyone have ideas on how I can 'wake' a monitor once a day using a script such as python? So ... my desktop computer in always on but at noon I would like the monitor to change from black to showing a message. I'm using Windows XP.
darter
 
Posts: 7
Joined: Sun Feb 10, 2013 5:19 am

Re: waking a sleeping monitor with python?

Postby Yoriz » Wed Mar 06, 2013 7:37 am

You'll need http://sourceforge.net/projects/pywin32/ if you dont have it already.
Give this a try.
Code: Select all
import time
import win32gui
import win32con

MONITOR_ON = -1
MONITOR_STANDBY = 1
MONITOR_OFF = 2
SC_MONITORPOWER = 0xF170

def monitorControl(state=MONITOR_ON):
    win32gui.SendMessage(win32con.HWND_BROADCAST, win32con.WM_SYSCOMMAND,
                                                    SC_MONITORPOWER, state)

if __name__ == "__main__":
    monitorControl(MONITOR_OFF)
    time.sleep(5)
    monitorControl(MONITOR_ON)
New Users, Read This
Join the #python-forum IRC channel on irc.freenode.net!
Spam topic disapproval technician
Windows7, Python 2.7.4., WxPython 2.9.5.0., some Python 3.3
User avatar
Yoriz
 
Posts: 789
Joined: Fri Feb 08, 2013 1:35 am
Location: UK

Re: waking a sleeping monitor with python?

Postby darter » Wed Mar 06, 2013 3:29 pm

Thanks. Works great on my XP machine. I also have a Window 7 laptop that I'm operating remotely and I am hoping it with work with Windows 7. On the remote machine I just want to be careful that I don't crash it.
darter
 
Posts: 7
Joined: Sun Feb 10, 2013 5:19 am


Return to General Discussions

Who is online

Users browsing this forum: Bing [Bot] and 2 guests