Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!feeder.news-service.com!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.020 X-Spam-Evidence: '*H*': 0.96; '*S*': 0.00; '__name__': 0.07; 'python': 0.07; '"__main__":': 0.09; 'monitor': 0.12; 'def': 0.13; '-1)': 0.16; 'pause': 0.16; 'win32api': 0.16; 'win32con': 0.16; 'win32gui': 0.16; 'trying': 0.23; 'reason,': 0.23; 'script': 0.26; 'windows': 0.26; "i'm": 0.26; 'message-id:@mail.gmail.com': 0.28; "doesn't": 0.28; 'hi,': 0.29; 'import': 0.32; 'to:addr:python- list': 0.32; 'there': 0.35; '2.6': 0.35; 'doing': 0.36; 'some': 0.37; 'received:209.85': 0.37; 'received:google.com': 0.38; 'to:addr:python.org': 0.39; 'received:209': 0.39; 'header:Received:5': 0.40; 'back': 0.61; 'here': 0.65; 'subject:off': 0.73; 'received:209.85.210.174': 0.84; 'received :mail-iy0-f174.google.com': 0.84 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:date:message-id:subject:from:to :content-type; bh=kDuFwBcGNssxNHtNhgJX3Z68euwEKI9F7ZDZ6tFS6Yw=; b=jswcIXmEdPd9ms3f4u1rsP+1ZUn6mQe8rRTpc+bCzV3RjI5L5boHCQOAblpVh9cPJS 47TwBbvD9BAqy24WarU8tNwlesq3ewt0cUaNy33PqlFyhxbh7B5duEt+zpy85c4ty2L1 Kt3ivXEWMNhYgZ1LEy7o+EXHqU9byOxNsTJy4= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type; b=M4E/7vfwAeY9AB7deKVXHjNgySl3p6zSi5ruePuHDtzjnSfFnmtzpeMkfA3G9culHc +P1kOp/afT3wOdqTvpwisIfzTmYX13DTAynIP/CIsjiPvNSaWdrcvYLoMaOl8gQtOgA0 KYSHRXCQs48aZkNX6ahX64w64N8Bv7CQyhe78= MIME-Version: 1.0 Date: Sat, 14 May 2011 16:08:44 +1000 Subject: turn monitor off and on From: Astan Chee To: python-list@python.org Content-Type: text/plain; charset=ISO-8859-1 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 27 NNTP-Posting-Host: 82.94.164.166 X-Trace: 1305353327 news.xs4all.nl 81484 [::ffff:82.94.164.166]:40547 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:5337 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?