Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Win32::API and SPI_GETSCREENSAVETIMEOUT

by aplonis (Pilgrim)
on Jan 31, 2012 at 09:23 UTC ( #950985=perlquestion: print w/replies, xml ) Need Help??

aplonis has asked for the wisdom of the Perl Monks concerning the following question:

I was trying to determine the screensaver timeout via the Win32::API like so...

#!/usr/bin/perl -w use strict; use Win32::API; Win32::API->Import("kernel32", "INT SPI_GETSCREENSAVETIMEOUT()"); my $foo = SPI_GETSCREENSAVETIMEOUT();

...but it's getting me nowhere. I get this error...

Undefined subroutine &main::SPI_GETSCREENSAVETIMEOUT called at ...

...even though a similar coding works for...

Win32::API->Import("kernel32", "int GetCurrentProcessId()"); $PID = GetCurrentProcessId();

I got the parameter from here: msdn.microsoft.com

I'd like to intelligently set the timing on my screensaver defeat script. Possibly I'd like for the script to let the user turn screensaving off for a period via SPI_SETSCREENSAVEACTIVE or some other method.

Replies are listed 'Best First'.
Re: Win32::API and SPI_GETSCREENSAVETIMEOUT
by Anonymous Monk on Jan 31, 2012 at 09:37 UTC

      Thank you. That is moderately helpful information, especially the forepart. I'm not a Win32 guru or even very much adept in Perl anymore. So I'm back to making newbie errors. Embarrassing, but there it is.

      Still I like to update my old scripts if folks (expecially myself) still find them useful. And this one apparently other people even besides myself still do. The whole reason for this particular script is to defeat the IT admin mandated screensaver policy of every few minutes requiring activity or a screen lock. They cannot be made to understand that while it is right and proper for the CAD designers to not leave their IP up while going on break it is a whole different story for us test engineers who have to go into the test cells to turn a valve, measure a voltage and so forth while expecting to come back after two minutes to the PC controlling our test to that we might adjust a pressure or flow...or to hit pause (not E-stop) in a semi- (but not all out) emergency. Having to constantly be re-logging in can upset the timing of a test and adversely affect the result.

      In short, I have to do it with Perl, not via the regular Windows way (because that is disabled by default). Local IT admins in my last two jobs have sagely understood and not very loudly objected to sparing use of a screensaver defeat script (mine, in fact, at both places) for some years now. But neither have either of them been willing to fight the good fight to push this issue with their own higher-ups out-of-state or overseas.

      Now the same script which has worked for years is only semi-reliable on Win7 while it was fine on Vista, XP and 2000. I added in Tye's mouse-jiggle function to no additional increase of reliability. So I'm still wanting to make it wholly reliable again. I want to do that for myself and everyone who seems to like it. I need to do it in Perl. Anyone with a helpful example to offer will be very appreciated. Thank you.

        Take a look at caffeine.exe. This is a utility which effectively prevent a system from lock also on Win7.

        Wait what?

Re: Win32::API and SPI_GETSCREENSAVETIMEOUT
by Corion (Pope) on Jan 31, 2012 at 09:36 UTC

    Where from that documentation do you get the impression that SPI_GETSCREENSAVETIMEOUT would be a function? Especially as the title of that page claims "SystemParametersInfo function"

      Okay, so it's HUGE document and I didn't read the whole thing. Also I do Perl very seldom nowadays being mostly immersed in LabVIEW. Negativity isn't helping. Why did you even bother with this sarcastic reply?

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://950985]
Approved by sundialsvc4
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (5)
As of 2019-07-18 07:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?