Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #5337 > unrolled thread
| Started by | Astan Chee <astan.chee@gmail.com> |
|---|---|
| First post | 2011-05-14 16:08 +1000 |
| Last post | 2011-05-15 20:48 -0500 |
| Articles | 11 — 6 participants |
Back to article view | Back to comp.lang.python
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
| From | Astan Chee <astan.chee@gmail.com> |
|---|---|
| Date | 2011-05-14 16:08 +1000 |
| Subject | turn monitor off and on |
| Message-ID | <mailman.1537.1305353327.9059.python-list@python.org> |
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?
[toc] | [next] | [standalone]
| From | harrismh777 <harrismh777@charter.net> |
|---|---|
| Date | 2011-05-14 02:13 -0500 |
| Message-ID | <VYpzp.28137$Vp.6741@newsfe14.iad> |
| In reply to | #5337 |
Astan Chee wrote: > 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() What we need here is a matching script that turns off WinXP and leaves it off too... ... ouch, <sorry, couldn't help myself> :) lol m harris
[toc] | [prev] | [next] | [standalone]
| From | harrismh777 <harrismh777@charter.net> |
|---|---|
| Date | 2011-05-14 02:20 -0500 |
| Message-ID | <r3qzp.174$cs1.146@newsfe15.iad> |
| In reply to | #5340 |
harrismh777 wrote: > > def turnOnMonitor(): > SC_MONITORPOWER = 0xF170 > win32gui.SendMessage(win32con.HWND_BROADCAST, > win32con.WM_SYSCOMMAND, SC_MONITORPOWER, -1) I've never tried turning my monitor on/off without using my finger... gonna have to play with this... wouldn't that be a great script kiddie tool... just turn off all the windows monitors around the world... no problem(s) after that... ... what happens if you try to turn it back on with your finger... ? ... I have another idea... while its off, try pushing the alt key on your keyboard... or moving your mouse... (come back on ? ) kind regards, m harris
[toc] | [prev] | [next] | [standalone]
| From | harrismh777 <harrismh777@charter.net> |
|---|---|
| Date | 2011-05-14 02:29 -0500 |
| Message-ID | <2bqzp.1932$7N5.281@newsfe04.iad> |
| In reply to | #5341 |
harrismh777 wrote: >> >> def turnOnMonitor(): >> SC_MONITORPOWER = 0xF170 >> win32gui.SendMessage(win32con.HWND_BROADCAST, >> win32con.WM_SYSCOMMAND, SC_MONITORPOWER, -1) Wonder what the equivalent of this is in Linux... ?
[toc] | [prev] | [next] | [standalone]
| From | Alexander Kapps <alex.kapps@web.de> |
|---|---|
| Date | 2011-05-14 09:59 +0200 |
| Message-ID | <mailman.1540.1305359993.9059.python-list@python.org> |
| In reply to | #5343 |
On 14.05.2011 09:29, harrismh777 wrote:
> harrismh777 wrote:
>>>
>>> def turnOnMonitor():
>>> SC_MONITORPOWER = 0xF170
>>> win32gui.SendMessage(win32con.HWND_BROADCAST,
>>> win32con.WM_SYSCOMMAND, SC_MONITORPOWER, -1)
>
>
> Wonder what the equivalent of this is in Linux... ?
Probably xset dpms force {on,off,...}
[toc] | [prev] | [next] | [standalone]
| From | Steven D'Aprano <steve+comp.lang.python@pearwood.info> |
|---|---|
| Date | 2011-05-14 07:43 +0000 |
| Message-ID | <4dce3290$0$29980$c3e8da3$5496439d@news.astraweb.com> |
| In reply to | #5341 |
On Sat, 14 May 2011 02:20:55 -0500, harrismh777 wrote: > harrismh777 wrote: >> >> def turnOnMonitor(): >> SC_MONITORPOWER = 0xF170 >> win32gui.SendMessage(win32con.HWND_BROADCAST, >> win32con.WM_SYSCOMMAND, SC_MONITORPOWER, -1) > > > I've never tried turning my monitor on/off without using my finger... You've never had your PC turn your monitor off after X minutes of inactivity? > gonna have to play with this... wouldn't that be a great script kiddie > tool... just turn off all the windows monitors around the world... no > problem(s) after that... > > ... what happens if you try to turn it back on with your finger... ? Then you actually turn it off, at the power switch, instead of merely off in software. > ... I have another idea... while its off, try pushing the alt key on > your keyboard... or moving your mouse... (come back on ? ) Presumably you would need to program something to watch for activity and turn it back on. It would be somewhat embarrassing if you neglected to so this... -- Steven
[toc] | [prev] | [next] | [standalone]
| From | harrismh777 <harrismh777@charter.net> |
|---|---|
| Date | 2011-05-14 03:05 -0500 |
| Message-ID | <XIqzp.674$VK6.58@newsfe22.iad> |
| In reply to | #5346 |
Steven D'Aprano wrote: >> I've never tried turning my monitor on/off without using my finger... > You've never had your PC turn your monitor off after X minutes of > inactivity? I know you're being funny, but actually, no-- I don't. That's a back-in-the-day thing... all of my monitors (and I only have a couple now because I use VNC to get to the rest of my machines) are flat panel LED, very low power, cool, and virtually indestructible. I just leave them on... with beautiful screen savers running... which aren't screen savers these days either... because nothing really burns... more like perpetual light-candy eye-pleasers... Sure, back in the day I configured my system to shutoff the CRT... but honestly, I haven't had a CRT for almost a decade... you can still shutdown the flat panel several different ways on the linux platform based on timing if you want to... in BIOS, in the OS, in gnome, using the xscreensaver, etc... but, no, I have never written a code routine to shutoff the monitor (my finger always worked just fine). :) I wrote a code routine one time just to open the drive bay door, timer(), and then close the door... from across the network... until my wife got wise to it, I would open her drive bay door over the network... it was fun for a while, even after she got wise to it... ... till the morning I tried it and she had a cup of cocoa sitting on the desk in front of the drive bay... ... there have been better days in my house. :)
[toc] | [prev] | [next] | [standalone]
| From | Terry Reedy <tjreedy@udel.edu> |
|---|---|
| Date | 2011-05-14 15:58 -0400 |
| Message-ID | <mailman.1559.1305403125.9059.python-list@python.org> |
| In reply to | #5341 |
On 5/14/2011 3:20 AM, harrismh777 wrote: > harrismh777 wrote: >> >> def turnOnMonitor(): >> SC_MONITORPOWER = 0xF170 >> win32gui.SendMessage(win32con.HWND_BROADCAST, >> win32con.WM_SYSCOMMAND, SC_MONITORPOWER, -1) > > > I've never tried turning my monitor on/off without using my finger... The computer cannot turn off the monitor. It can only tell the graphics card to turnoff the signal to the monitor. My monitor then displays 'No signal detected' in a box and puts itself into a low-power state awaiting a signal. Even if the monitor does not do that, a black screen should use less power. Why the turnon does not work, if indeed it does not (and the monitor is not failing to respond to its resumption) is not a Python question. 2 and -1 as off and on parameters is a bit strange. The OP might try a different api reference source or ask on a windows innards list. -- Terry Jan Reedy
[toc] | [prev] | [next] | [standalone]
| From | harrismh777 <harrismh777@charter.net> |
|---|---|
| Date | 2011-05-14 19:25 -0500 |
| Message-ID | <74Fzp.572$ar1.165@newsfe08.iad> |
| In reply to | #5382 |
Terry Reedy wrote: > The computer cannot turn off the monitor. ... this was my point ;-)
[toc] | [prev] | [next] | [standalone]
| From | Gregory Ewing <greg.ewing@canterbury.ac.nz> |
|---|---|
| Date | 2011-05-16 12:00 +1200 |
| Message-ID | <93b7o1Fb92U1@mid.individual.net> |
| In reply to | #5382 |
Terry Reedy wrote: > My monitor then displays 'No > signal detected' in a box and puts itself into a low-power state > awaiting a signal. Even if the monitor does not do that, a black screen > should use less power. I'm not so sure about that. If the monitor is an LCD and isn't doing anything to reduce its own power usage, then the backlight is still running and using just as much power, whether the screen is black or not. -- Greg
[toc] | [prev] | [next] | [standalone]
| From | harrismh777 <harrismh777@charter.net> |
|---|---|
| Date | 2011-05-15 20:48 -0500 |
| Message-ID | <Wn%zp.7973$ar1.7638@newsfe08.iad> |
| In reply to | #5450 |
Gregory Ewing wrote: > I'm not so sure about that. If the monitor is an LCD and isn't > doing anything to reduce its own power usage, then the backlight > is still running and using just as much power, whether the screen > is black or not. Depends on dpmi. Some monitors turn off the backlight, and some don't. My monitor(s) that are LCD turn off the backlight... and the downside of that (very annoying) is that they have to 'warm up' again... making them dim for the first few seconds of use... An LED flat panel is a completely different animal, because there is no backlight (no ccfl). They monitors don't use much power in the first place, but they use less when they're blank, obviously, not producing light. kind regards, m harris
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.python
csiph-web