473,322 Members | 1,781 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

fire event if screensaver starts

hi i want to fire an event if the screen saver starts up
i have done it using a timer tick event where i have used the api
function to detect if screensaver has started..but this means
continuous polling at each timer click..

private void tick(object sender, System.EventArgs e)
{
const int SPI_GETSCREENSAVERRUNNING = 114;
int screenSaverRunning = -1;
// is the screen saver running?

int ok = SystemParametersInfo(SPI_GETSCREENSAVERRUNNING, 0, ref
screenSaverRunning, 0);

if (ok == 0)
{
Console.WriteLine("Call to SystemParametersInfo failed.");

}
if (screenSaverRunning != 0)
{
// screen saver is running
MessageBox.Show("screensaver runs");

}
else
{
}
}

is there a better way of doing something like no use of timer..
i want someting like-- if screensaver starts then a event gets fired
and if screen saver stops another event gets fired..this wud avoid
getting in the loop of timer tick event..
So my question is "is it possible to just fire events if screen saver
starts or stops without using timer ??"

Nov 17 '05 #1
3 9227

sanjana wrote:
hi i want to fire an event if the screen saver starts up


There doesn't seem to be a Framework way of dealing with this, which
means you're going to have to do it the old-fashioned way.

Note that there isn't normally a global message sent when the
screensaver starts - only the active top level window gets a
WM_SYSCOMMAND message, with wParam set to SC_SCREENSAVE. So to be
notified of screensaver startup whether you are the active top level
window or not, you need to create a hook that catches that message then
sends a broadcast message of your own to all top level windows.

The full info is here in this Ask Dr GUI #48 article from way back:

<http://msdn.microsoft.com/library/default.asp?url=/archive/en-us/dnaraskdr/html/drgui48.asp>

The other alternative, as you have found, is to poll
SystemParametersInfo.

--
Larry Lard
Replies to group please

Nov 17 '05 #2
Hi,

http://dotnet.mvps.org/dotnet/samples/operatingsystem/

There you will find a demo, it's in german or something like that, but the
code is easy to understand :)

I never used it though.
cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"sanjana" <su****@gmail.com> wrote in message
news:11*********************@g14g2000cwa.googlegro ups.com...
hi i want to fire an event if the screen saver starts up
i have done it using a timer tick event where i have used the api
function to detect if screensaver has started..but this means
continuous polling at each timer click..

private void tick(object sender, System.EventArgs e)
{
const int SPI_GETSCREENSAVERRUNNING = 114;
int screenSaverRunning = -1;
// is the screen saver running?

int ok = SystemParametersInfo(SPI_GETSCREENSAVERRUNNING, 0, ref
screenSaverRunning, 0);

if (ok == 0)
{
Console.WriteLine("Call to SystemParametersInfo failed.");

}
if (screenSaverRunning != 0)
{
// screen saver is running
MessageBox.Show("screensaver runs");

}
else
{
}
}

is there a better way of doing something like no use of timer..
i want someting like-- if screensaver starts then a event gets fired
and if screen saver stops another event gets fired..this wud avoid
getting in the loop of timer tick event..
So my question is "is it possible to just fire events if screen saver
starts or stops without using timer ??"

Nov 17 '05 #3
hi there
thanx a lot ..it worked:)
Ignacio Machin ( .NET/ C# MVP ) wrote:
Hi,

http://dotnet.mvps.org/dotnet/samples/operatingsystem/

There you will find a demo, it's in german or something like that, but the
code is easy to understand :)

I never used it though.
cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"sanjana" <su****@gmail.com> wrote in message
news:11*********************@g14g2000cwa.googlegro ups.com...
hi i want to fire an event if the screen saver starts up
i have done it using a timer tick event where i have used the api
function to detect if screensaver has started..but this means
continuous polling at each timer click..

private void tick(object sender, System.EventArgs e)
{
const int SPI_GETSCREENSAVERRUNNING = 114;
int screenSaverRunning = -1;
// is the screen saver running?

int ok = SystemParametersInfo(SPI_GETSCREENSAVERRUNNING, 0, ref
screenSaverRunning, 0);

if (ok == 0)
{
Console.WriteLine("Call to SystemParametersInfo failed.");

}
if (screenSaverRunning != 0)
{
// screen saver is running
MessageBox.Show("screensaver runs");

}
else
{
}
}

is there a better way of doing something like no use of timer..
i want someting like-- if screensaver starts then a event gets fired
and if screen saver stops another event gets fired..this wud avoid
getting in the loop of timer tick event..
So my question is "is it possible to just fire events if screen saver
starts or stops without using timer ??"


Nov 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: klappnase | last post by:
Hello everyone, does anyone know a way to stop the screensaver under linux from starting up while a certain process is running? I need this because I experience a memory leak while recording...
3
by: alexB | last post by:
On my ASP.NET application, restarting the application through IIS doesn't always fire the Application_Start() event. Is there a trick to this? Restarting IIS is not an option since there are...
0
by: Luke | last post by:
I am trying to capture an event when the screensaver starts. I have code working on Windows XP etc when the Password/Welcome Screen is enabled . Using the Fast User Switching Notifications. ...
2
by: Kevin Ly | last post by:
Consider the test case below. The onmouseout event does NOT fire when my mouse/cusor is moved off the left side of the browser. It does if it is moved off the top, bottom, and the right side that...
4
by: Paul Smith | last post by:
I have been given an unusual task to create a Windows Service to do something periodically to make the screensaver timer reset. We have a general policy of locking computers automatically after 10...
4
by: Simon Mercer | last post by:
I have been trying to build a screensaver that will connect to a database and display specific data depending on the user that is logged in. I have managed to get a simple data access screensaver...
5
by: Carlo Marchesoni | last post by:
From an aspx page (A.aspx) I open another one (B.aspx - for table lookup). When the user selects an entry in B.aspx I would like to force a button's event in A.aspx to be fired. I guess the only...
7
by: Gordon Smith | last post by:
I have four (4) ASP.NET Web applications/Web sites on a IIS/6 - Windows Server 2003 production server. 3 of them work fine. I just installed the 4th one and it's Application_Start event is not...
0
by: tshad | last post by:
In VS 2008, I have 2 pages, one aspx page and one ascx page. The PreRender event is not firing on the Contol page. The aspx page starts out: <%@ Page Language="VB" AutoEventWireup="true"...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.