Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #5337

turn monitor off and on

Date 2011-05-14 16:08 +1000
Subject turn monitor off and on
From Astan Chee <astan.chee@gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.1537.1305353327.9059.python-list@python.org> (permalink)

Show all headers | View raw


Hi,
I'm trying to turn off my monitor, pause and then turn it on again.
I'm doing this in python 2.6 and windows xp. Here is my script so far
(that doesn't work):

import time
import win32gui
import win32con
import win32api

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

def turnOnMonitor():
  SC_MONITORPOWER = 0xF170
  win32gui.SendMessage(win32con.HWND_BROADCAST,
win32con.WM_SYSCOMMAND, SC_MONITORPOWER, -1)

if __name__ == "__main__":
  turnOffMonitor()
  time.sleep(5)
  turnOnMonitor()

For some reason, the script doesn't turn the monitor back on. What am
I doing wrong here or are there any other alternative?

Back to comp.lang.python | Previous | NextNext in thread | Find similar | Unroll thread


Thread

turn monitor off and on Astan Chee <astan.chee@gmail.com> - 2011-05-14 16:08 +1000
  Re: turn monitor off and on harrismh777 <harrismh777@charter.net> - 2011-05-14 02:13 -0500
    Re: turn monitor off and on harrismh777 <harrismh777@charter.net> - 2011-05-14 02:20 -0500
      Re: turn monitor off and on harrismh777 <harrismh777@charter.net> - 2011-05-14 02:29 -0500
        Re: turn monitor off and on Alexander Kapps <alex.kapps@web.de> - 2011-05-14 09:59 +0200
      Re: turn monitor off and on Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-05-14 07:43 +0000
        Re: turn monitor off and on harrismh777 <harrismh777@charter.net> - 2011-05-14 03:05 -0500
      Re: turn monitor off and on Terry Reedy <tjreedy@udel.edu> - 2011-05-14 15:58 -0400
        Re: turn monitor off and on harrismh777 <harrismh777@charter.net> - 2011-05-14 19:25 -0500
        Re: turn monitor off and on Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2011-05-16 12:00 +1200
          Re: turn monitor off and on harrismh777 <harrismh777@charter.net> - 2011-05-15 20:48 -0500

csiph-web