Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Activating a screen saver problems

by palkia (Scribe)
on May 27, 2012 at 23:17 UTC ( #972758=perlquestion: print w/ replies, xml ) Need Help??
palkia has asked for the wisdom of the Perl Monks concerning the following question:

Hello
I've tried to run a screen saver (with standby) by doing what I've always done with other things:
system('C:/WINDOWS/system32/scrnsave.scr');
But from some reason it runs the "options" of that screen saver instead.

I figured that the double click runs it, because of the default defined in some os level,
so I've right-clicked it and saw the default (bolded)option was "Test" os I tried to access that by:
system('C:/WINDOWS/system32/scrnsave.scr','Test'); system('Test','C:/WINDOWS/system32/scrnsave.scr'); system('C:/WINDOWS/system32/scrnsave.scr','test'); system('test','C:/WINDOWS/system32/scrnsave.scr');
All 4 failed.
So just to cover my bases I tried:
system('C:/WINDOWS/system32/scrnsave.scr','Run'); system('Run','C:/WINDOWS/system32/scrnsave.scr'); system('C:/WINDOWS/system32/scrnsave.scr','run'); system('run','C:/WINDOWS/system32/scrnsave.scr');
Again all failed.

Please help
Thx

Comment on Activating a screen saver problems
Select or Download Code
Replies are listed 'Best First'.
Re: Activating a screen saver problems
by golux (Pilgrim) on May 28, 2012 at 00:37 UTC
    Hi palkia,

    I think you want the "/s" switch to the screensaver program.

    This works for me, for example (if I'm in the screensaver directory):

    #!/usr/bin/perl -w use strict; use warnings; my $scr = "sspipes.scr"; system("$scr/s");
    Good luck!

    Update:  Trying it with a random screensaver works too, so it seems /s is the correct, general solution.  Again (lazily) from within the screensaver directory:

    #!/usr/bin/perl -w use strict; use warnings; my @ss = glob("*.scr"); my $scr = $ss[rand @ss]; system("$scr/s");
    say  substr+lc crypt(qw $i3 SI$),4,5
      I have no idea what #!/usr/bin/perl -w does,
      I've never heard about '/s',
      and the requirement to be in the screensaver directory doesn't make any sense to me.

      Regardless my experiments confirmed both the '/s',
      and the directory necessities (guess I got more fundamentals to learn than I thought ^^).
      Thank you very much, it works gr8.
        Hi palkia,

        By "be in the screensaver directory", I only meant that you have to run my script from wherever the screensavers are located. In my case it's C:\WINNT\system32, in your case it's apparently C:\WINDOWS\system32. But since you're giving the whole path, that's fine too.

        The #!/usr/bin/perl -w line is not as important in Windows as in Linux, although the -w is quite useful (it enables "warnings"). You can read about "warnings" and "strict" in the perllexwarn documentation.

        I wrote a screensaver in Perl several years ago (haven't finished it though), and remembered there was a way to invoke a screensaver from the command line. A search quickly led me to the /s switch.

        Good luck and much enjoyment with your continued path in Perl!

        say  substr+lc crypt(qw $i3 SI$),4,5

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (14)
As of 2015-07-30 23:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (273 votes), past polls