Blocking Screensaver from Appearing

G

Guest

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 minutes of inactivity. This
windows service would be used on some machines to prevent the lock from
occurring every 10 minutes.

I have tried to reposition the mouse pointer with the Cursor class in a
service, but it does not work -- always sees the cursor at 0,0 and does not
recognize a new position being set for it. I have also looked for something
to directly reset the timer the screensaver uses, but have found nothing.

If someone could suggest a straightforward way to capture the real mouse
coordinates from a .NET Windows Service, so I can nudge the mouse to prevent
the screensaver from appearing, or to directly reset the screensaver timer,
that would be most helpful. We can not just set Windows properties (like
screensaver to none), as we do not want users to be able to prevent the
screensaver from appearing.
 
G

Guest

Paul,
I went through the same exercise a while back. Unfortunately,
programmatically moving the mouse won't do it. If you use a Group Policy to
set the screensaver I can tell you it's a semi-futile effort to try to
override that to any extent. My spec was to set the timeout, active flag,
start time, end time, etc.

I ended up writing a .net service that checks a registry setting on a
periodic basis. If the setting was 1 the set it to 0. The registry key is
HKEY_Users\Software\Policies\Microsoft\Windows\Control
Panel\Desktop\ScreenSaveActive. Also note that if you are using a service
under the local system context, you'll need to iterate through all the logged
on users in the HKEY_USERS hive and set the \ScreenSaveActive bit
appropriately.

If you're not using group policy for the screen saver there are api calls
you can make that are fairly simple.

-Mike
 
G

Guest

Mike,

Thank you. We are using a group policy, so I will approach it as resetting
these registry keys.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top