Screensaver Event?

If you have a question or need help, this is the place to be.

Screensaver Event?

Postby spazlon » Sat Jun 18, 2011 8:58 am

Hello,

I am trying to turn off my TV when the screensaver is activated and turn on the TV when the screensaver is deactivated.

I have the TV on/off functions working, but I can't find the event for the screensaver. What can I use to accomplish this?

Thank you,

Ryan
spazlon
 
Posts: 14
Joined: Fri Jun 17, 2011 6:43 pm
Location: Mangaf, Kuwait

Re: Screensaver Event?

Postby jonib » Sat Jun 18, 2011 8:29 pm

spazlon wrote:I have the TV on/off functions working, but I can't find the event for the screensaver. What can I use to accomplish this?
The "Task Create/Switch Events" plugin generates several events on my WinXP when the screensaver is activated.

jonib
XBMC2 plugin to control XBMC. If you want to flatter me Image
jonib
Plugin Developer
 
Posts: 713
Joined: Thu Mar 26, 2009 9:33 pm

Re: Screensaver Event?

Postby Pako » Sun Jun 19, 2011 6:41 am

If you are using still the same screen saver, you can use for your purpose the Application Observer plugin.
I just added there to observe not only the application type .exe, but also type .scr.
For example, the 3D Text screensaver you simply add to observe by adding the ssText3d.scr applications.

If you change screensaver sometimes, it's better to use this script:
Code: Select all
period = 2.0  #Test every 2 seconds

SPI_GETSCREENSAVERRUNNING  = 0x72
from ctypes import byref, c_bool
from ctypes.wintypes import WinDLL
saverRunning = c_bool()


def CheckScreensaverRunning():
    WinDLL("user32").SystemParametersInfoA(SPI_GETSCREENSAVERRUNNING, 0, byref(saverRunning), False)
    running  = saverRunning.value
    if running != eg.globals.ScreenSaverRunning:
        eg.globals.ScreenSaverRunning = running
        eg.TriggerEvent("ScreensaverRunning.%s" % str(running), prefix="System")
    eg.scheduler.AddTask(period, CheckScreensaverRunning)

eg.globals.ScreenSaverRunning = None
CheckScreensaverRunning()
The script should be placed into a macro that will be triggered after start by event Main.OnInit.
OnInit.gif
OnInit.gif (2.3 KiB) Viewed 786 times
Pako
User avatar
Pako
Plugin Developer
 
Posts: 1282
Joined: Sat Nov 11, 2006 1:31 pm
Location: Czech Republic

Re: Screensaver Event?

Postby spazlon » Sun Jun 19, 2011 8:23 am

jonib wrote:The "Task Create/Switch Events" plugin generates several events on my WinXP when the screensaver is activated.


This didn't work for me because when the screensaver was activated the dekstop event would fire. This means if the screensaver came on, the TV would turn off, but also if I minimized MCE the TV would also turn off.

Pako wrote:
Code: Select all
period = 2.0  #Test every 2 seconds

SPI_GETSCREENSAVERRUNNING  = 0x72
from ctypes import byref, c_bool
from ctypes.wintypes import WinDLL
saverRunning = c_bool()


def CheckScreensaverRunning():
    WinDLL("user32").SystemParametersInfoA(SPI_GETSCREENSAVERRUNNING, 0, byref(saverRunning), False)
    running  = saverRunning.value
    if running != eg.globals.ScreenSaverRunning:
        eg.globals.ScreenSaverRunning = running
        eg.TriggerEvent("ScreensaverRunning.%s" % str(running), prefix="System")
    eg.scheduler.AddTask(period, CheckScreensaverRunning)

eg.globals.ScreenSaverRunning = None
CheckScreensaverRunning()


I will give this a try when I get home tonight. This looks like a solid solution. I see how it will fire an event when the screensaver is activated, but when the screensaver is deactivated will it fire another event?

Thanks for the quick replies guys!!
spazlon
 
Posts: 14
Joined: Fri Jun 17, 2011 6:43 pm
Location: Mangaf, Kuwait

Re: Screensaver Event?

Postby Pako » Sun Jun 19, 2011 9:25 am

spazlon wrote: I see how it will fire an event when the screensaver is activated, but when the screensaver is deactivated will it fire another event?
Of course yes.
Code: Select all
System.ScreensaverRunning.True
System.ScreensaverRunning.False
Pako
User avatar
Pako
Plugin Developer
 
Posts: 1282
Joined: Sat Nov 11, 2006 1:31 pm
Location: Czech Republic

Re: Screensaver Event?

Postby jonib » Sun Jun 19, 2011 11:35 am

spazlon wrote:This didn't work for me because when the screensaver was activated the dekstop event would fire. This means if the screensaver came on, the TV would turn off, but also if I minimized MCE the TV would also turn off.
I got these events when the screensaver activated Task.Created.scrnsave, Task.NewWindow.scrnsave and Task.Activated.scrnsave.
And when the screensaver deactivated I got these events Task.Deactivated.scrnsave, Task.ClosedWindow.scrnsave and Task.Destroyed.scrnsave.

Don't you get those?

jonib
XBMC2 plugin to control XBMC. If you want to flatter me Image
jonib
Plugin Developer
 
Posts: 713
Joined: Thu Mar 26, 2009 9:33 pm

Re: Screensaver Event?

Postby Pako » Sun Jun 19, 2011 11:56 am

I get only this (timeout = 1 min; OS = Windows 7):
Code: Select all
13:49:36   System.Idle
13:49:57   Task.Deactivated.pn
13:49:57   Task.Activated.Desktop
13:52:02   System.UnIdle
13:52:02   Task.Deactivated.Desktop
13:52:02   Task.Activated.pn
Pako
User avatar
Pako
Plugin Developer
 
Posts: 1282
Joined: Sat Nov 11, 2006 1:31 pm
Location: Czech Republic

Re: Screensaver Event?

Postby spazlon » Sun Jun 19, 2011 11:57 am

jonib wrote:
spazlon wrote:This didn't work for me because when the screensaver was activated the dekstop event would fire. This means if the screensaver came on, the TV would turn off, but also if I minimized MCE the TV would also turn off.
I got these events when the screensaver activated Task.Created.scrnsave, Task.NewWindow.scrnsave and Task.Activated.scrnsave.
And when the screensaver deactivated I got these events Task.Deactivated.scrnsave, Task.ClosedWindow.scrnsave and Task.Destroyed.scrnsave.

Don't you get those?

jonib


Nope, I'm at work right now so I can't get the logs, but it was something like Application.Desktop when the screensaver was activated and Application.MediaCenter when the screensaver was deactivated.

I will play with it some more tonight when I get home.
spazlon
 
Posts: 14
Joined: Fri Jun 17, 2011 6:43 pm
Location: Mangaf, Kuwait

Re: Screensaver Event?

Postby spazlon » Sun Jun 19, 2011 11:58 am

Pako wrote:I get only this (timeout = 1 min; OS = Windows 7):
Code: Select all
13:49:36   System.Idle
13:49:57   Task.Deactivated.pn
13:49:57   Task.Activated.Desktop
13:52:02   System.UnIdle
13:52:02   Task.Deactivated.Desktop
13:52:02   Task.Activated.pn
Pako



Bah, you posted when I was composing that last post.

I'm pretty sure those are the same log events I get as well.

Pako, I will try your method tonight.

Thanks again guys!
spazlon
 
Posts: 14
Joined: Fri Jun 17, 2011 6:43 pm
Location: Mangaf, Kuwait

Re: Screensaver Event?

Postby spazlon » Sun Jun 19, 2011 6:57 pm

Pako -

This ended up working perfectly. Thanks!

Now I just need to see if it will work while I am in Media Center. I don't remember the name of the screensaver it runs.

Thanks again!
spazlon
 
Posts: 14
Joined: Fri Jun 17, 2011 6:43 pm
Location: Mangaf, Kuwait


Return to General Support

Who is online

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