Click here to Skip to main content
15,889,595 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to know how can we track the system idle state. For example as seen in windows screensaver which starts when system is idle for specified time and as soon as we move mouse or press any key on keyboard the screensaver stops.

So how to trace that system idle state and also the duration since it is in that idle state and finally how or when it came out of that state?
Posted

1 solution

There are two ways of detecting if a screensaver is active.
You can call the SystemParametersInfo()
(http://msdn2.microsoft.com/en-us/library/ms724947.aspx[^])
API function passing the SPI_GETSCREENSAVERRUNNING flag (for an example look at this:
(http://www.codeguru.com/forum/showthread.php?t=257949[^])). You can create a global Windows message hook, and intercept the WM_SYSCOMMAND message. When you find this message, check to see if wParam is SC_SCREENSAVE. This is a bit more of a pain in C# than C/C++, but it's definitely doable. For more information have a look at this:
(http://msdn.microsoft.com/library/default.asp?url=/archive/en-us/dnaraskdr/html/drgui48.asp[^]).

I'd suggest you get used to Googling, as there's already a stack of information out there for handling keyboard and mouse input in C#
(such as this (http://www.codeproject.com/csharp/globalhook.asp[^])
and this (http://www.codeguru.com/csharp/csharp/cs_syntax/anandctutorials/article.php/c5823/[^])).


GL
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900