Notice: This forum has been recovered from an old backup, so some content, links, and dates may be outdated. The forum is currently read-only while we restore sign-in and registration functionality. Details

If you find this forum valuable and would like to help keep it online, donations to help cover hosting and domain costs are greatly appreciated, but never expected. You can support the forum through Buy Me a Coffee or Ko-fi. Thank you for helping preserve the EventGhost community.

Screensaver Event?

If you have a question or need help, this is the place to be.
Post Reply
spazlon
Posts: 14
Joined: Fri Jun 17, 2011 6:43 pm
Location: Mangaf, Kuwait
Contact:

Screensaver Event?

Post by spazlon »

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
jonib
Plugin Developer
Posts: 1328
Joined: Thu Mar 26, 2009 9:33 pm
Location: Sweden

Re: Screensaver Event?

Post by jonib »

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
User avatar
Pako
Plugin Developer
Posts: 2294
Joined: Sat Nov 11, 2006 1:31 pm
Location: Czech Republic
Contact:

Re: Screensaver Event?

Post by Pako »

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 3834 times
Pako
spazlon
Posts: 14
Joined: Fri Jun 17, 2011 6:43 pm
Location: Mangaf, Kuwait
Contact:

Re: Screensaver Event?

Post by spazlon »

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!!
User avatar
Pako
Plugin Developer
Posts: 2294
Joined: Sat Nov 11, 2006 1:31 pm
Location: Czech Republic
Contact:

Re: Screensaver Event?

Post by Pako »

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
jonib
Plugin Developer
Posts: 1328
Joined: Thu Mar 26, 2009 9:33 pm
Location: Sweden

Re: Screensaver Event?

Post by jonib »

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
User avatar
Pako
Plugin Developer
Posts: 2294
Joined: Sat Nov 11, 2006 1:31 pm
Location: Czech Republic
Contact:

Re: Screensaver Event?

Post by Pako »

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
spazlon
Posts: 14
Joined: Fri Jun 17, 2011 6:43 pm
Location: Mangaf, Kuwait
Contact:

Re: Screensaver Event?

Post by spazlon »

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
Contact:

Re: Screensaver Event?

Post by spazlon »

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
Contact:

Re: Screensaver Event?

Post by spazlon »

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!
Post Reply