On Tuesday, September 21, 2010 5:32 PM, Johan Vromans

> As you know by now, I'm writing some apps for my wife who got severely
> handicapped last year. The apps are for a touch screen PC running
> Windows.

Sorry to hear that :-(
[...]

> So, how can an application find out whether the screen saver is
active,
> or, more precisely, the screen is blanked? Can I do this using the
Win32
> core API?

I don't know, but I have a couple of guesses that you can try out.

First, I thought that most screensavers absorb the mouse click or
keystroke themselves.  Doesn't Windows's screen blanker do that?
That's annoying.

You could check to see whether your window loses focus when the
screen saver is active.  If not, you could choose not to process
mouse clicks when your window doesn't have the focus.  I know
that many Microsoft apps (such as Excel and Outlook) will not
process a mouse click when they don't have the focus -- this
prevents the user from clicking on a window (to give it focus)
and deleting something or sending an e-mail message, etc.

A bit of googling shows that there seems to be a Win32 system
call you can use, the SPI_GETSCREENSAVERRUNNING option to
SystemParametersInfo.  I'm guessing that you can probably call it
via Win32::API.  This:

    http://www.codeproject.com/KB/cs/ScreenSaverControl.aspx

is a C# library to access this information; if you can call
SystemParametersInfo from Perl (and I think you can), it should
be trivial to adapt the code, even if you don't know C#.

I hope this helps.  If you find something that does work, please
post it to the mailing list so we all can learn!

Thanks,
-- Eric

Reply via email to