Sign in to follow this  
Followers 0
Draygoes

Could someone please help me with this screen saver?

13 posts in this topic

Hi all.

I have spent all day on a screen saver that has been great for practice. Now I am looking for a way to create a .scr file to put into the system32 directory.

Heres my problem. I compile the test script into the directory to a .scr file. Problem is, no matter what I do, I cannot get it to do anything but skip right over the code. Even when I click configure.

Heres my code:

If UBound($CmdLine) > 1 Then
$Command = StringLeft($CmdLine[1], 2)
If $Command == "/c" Then
$mode = 0
ElseIf $Command == "/s" Then
$mode = 1
ElseIf $Command == "/p" Then
$mode = 2
Else
If @Compiled Then $mode = 0
EndIf
 
EndIf

Switch $mode ;0 - config, 1 - run, 2 - preview
    Case 0
        Run("config.exe")
    Case 1
        Run("Screen saver execute.exe")
EndSwitch

The worst part of it is, I have searched all over the forum and help file for examples for command line scripts that I can actually understand. I havent found any so far.

If somone could help me correct the code, that would be great.

Thanks everyone!!! :)


Spoiler

 

"If a vegetarian eats vegetables,What the heck does a humanitarian eat?"

"I hear voices in my head, but I ignore them and continue on killing."

"You have forced me to raise the indifference warning to beige, it's a beige alert people. As with all beige alerts please prepare to think about the possibility of caring."

An optimist says that giving someone power DOESN'T immediately turn them into a sadist. A pessimist says that giving someone power doesn't IMMEDIATELY turn them into a sadist.

 

 

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

I think the prob is your If statements. Try this.

If UBound($CmdLine) > 1 Then
    $Command = StringLeft($CmdLine[1], 2)
    If $Command == "/c" Then
        $mode = 0
    ElseIf $Command == "/s" Then
        $mode = 1
    ElseIf $Command == "/p" Then
        $mode = 2
    EndIf
EndIf
Edited by spudw2k

Share this post


Link to post
Share on other sites

When I tried to run it, I got this error:

---------------------------

AutoIt Error

---------------------------

Line 18 (File "C:\Users\draygoes\Desktop\Knight47 Wallpaper Screen saver\Knight47 Wallpaper ScreenSaver Advanced.au3"):

EndIf

Error: "EndIf" statement with no matching "If" statement.

---------------------------

OK

---------------------------

I am sorry this is takeing so long.


Spoiler

 

"If a vegetarian eats vegetables,What the heck does a humanitarian eat?"

"I hear voices in my head, but I ignore them and continue on killing."

"You have forced me to raise the indifference warning to beige, it's a beige alert people. As with all beige alerts please prepare to think about the possibility of caring."

An optimist says that giving someone power DOESN'T immediately turn them into a sadist. A pessimist says that giving someone power doesn't IMMEDIATELY turn them into a sadist.

 

 

Share this post


Link to post
Share on other sites

@draygoes...Look in the help file for "Command Line Parameters"...

Share this post


Link to post
Share on other sites

You prob have another bad if statement somewhere. If you wanna share the code provately, I'll be happy to look at it. What is before and upto Line 18?

Share this post


Link to post
Share on other sites

I am completely lost. Could you please clean up this code so that it will work, then explain to me how you did it?

Thanks everyone.

This is the complete source code:

If UBound($CmdLine) > 1 Then
    $Command = StringLeft($CmdLine[1], 2)
    If $Command == "/c" Then
        $mode = 0
    ElseIf $Command == "/s" Then
        $mode = 1
    ElseIf $Command == "/p" Then
        $mode = 2
    EndIf

Switch $mode ;0 - config, 1 - run, 2 - preview
    Case 0
        Run("config.exe")
    Case 1
        Run("Screen saver execute.exe")
EndSwitch

Spoiler

 

"If a vegetarian eats vegetables,What the heck does a humanitarian eat?"

"I hear voices in my head, but I ignore them and continue on killing."

"You have forced me to raise the indifference warning to beige, it's a beige alert people. As with all beige alerts please prepare to think about the possibility of caring."

An optimist says that giving someone power DOESN'T immediately turn them into a sadist. A pessimist says that giving someone power doesn't IMMEDIATELY turn them into a sadist.

 

 

Share this post


Link to post
Share on other sites

Sorry to bump, but the topic seems to have gone over to the seconed page.


Spoiler

 

"If a vegetarian eats vegetables,What the heck does a humanitarian eat?"

"I hear voices in my head, but I ignore them and continue on killing."

"You have forced me to raise the indifference warning to beige, it's a beige alert people. As with all beige alerts please prepare to think about the possibility of caring."

An optimist says that giving someone power DOESN'T immediately turn them into a sadist. A pessimist says that giving someone power doesn't IMMEDIATELY turn them into a sadist.

 

 

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

@draygoes..Try this...

#include <Array.au3>

;From the Help File...
;$CmdLine[0] is number of parameters
;$CmdLine[1] is param 1 (after the script name)
;$CmdLine[2] is param 2 etc

;For example you run some program with /s parameter....(Great.exe /s)
;To see what the hell are the values...display the array...if you get no values for the second element then you are passing the parameters incorrectly.
;_ArrayDisplay($CmdLine,"Check")


If $CmdLine[0] = 0 then 
    MsgBox(4096+48, "Oops...", "No Parameter Found, Please Try Again.")
Exit
Else

Select
    
    Case $CmdLine[1] = "/c"
    $mode=0

    Case $CmdLine[1] = "/s"
    $mode=1
    
    Case $CmdLine[1] = "/p"
    $mode=2
    
    Case Else;You need to use the case else because if you dont pass the parameters /c, /s, /p it needs to do something.
    $mode=-1

EndSelect



Switch $mode;0 - config, 1 - run, 2 - preview
    Case 0
        Run("config.exe")
    Case 1
        Run("Screen saver execute.exe")
EndSwitch

EndIf
Edited by DjDeep00

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

Yay!!! I finally understand command line perameters!!! Thanks friend.

Ok, now I have another problem. I have edited the script for testing so that it will display msgbox's insted of running files, so that I could test to see if this was correct.

Eather I havr the wrong ideas, the script is incorrect, or windows is passing the script with no parimeters at all.

Heres my edited code:

#include <Array.au3>

;From the Help File...
;$CmdLine[0] is number of parameters
;$CmdLine[1] is param 1 (after the script name)
;$CmdLine[2] is param 2 etc

;For example you run some program with /s parameter....(Great.exe /s)
;To see what the hell are the values...display the array...if you get no values for the second element then you are passing the parameters incorrectly.
;_ArrayDisplay($CmdLine,"Check")


If $CmdLine[0] = 0 then
    MsgBox(0,"","None")
Exit

Else

Select
    
    Case $CmdLine[1] = "/c"
    $mode=0
    Case $CmdLine[1] = "-c"
    $mode=0
    Case $CmdLine[1] = "c"
    $mode=0
    
    Case $CmdLine[1] = "/s"
    $mode=1
    
    Case $CmdLine[1] = "-s"
    $mode=1
    
    Case $CmdLine[1] = "s"
    $mode=1
    
    Case $CmdLine[1] = "/p"
    $mode=2
    Case $CmdLine[1] = "-p"
    $mode=2
    Case $CmdLine[1] = "p"
    $mode=2
    
    Case Else;You need to use the case else because if you dont pass the parameters /c, /s, /p it needs to do something.
    $mode=-1

EndSelect



Switch $mode;0 - config, 1 - run, 2 - preview
    Case 0
      MsgBox(0,"","Configure")
    Case 1
      msgbox(0,"","Run")
  Case 2
      MsgBox(0, "", "Preview")
EndSwitch

EndIf

To see what I mean, compile the script with a .scr extention and rightclick the file, click configure. No matter what you click, you will allways get none.

Edited by draygoes

Spoiler

 

"If a vegetarian eats vegetables,What the heck does a humanitarian eat?"

"I hear voices in my head, but I ignore them and continue on killing."

"You have forced me to raise the indifference warning to beige, it's a beige alert people. As with all beige alerts please prepare to think about the possibility of caring."

An optimist says that giving someone power DOESN'T immediately turn them into a sadist. A pessimist says that giving someone power doesn't IMMEDIATELY turn them into a sadist.

 

 

Share this post


Link to post
Share on other sites

Run from cmd console withs -s param. Works for me.

Share this post


Link to post
Share on other sites

I am sorry, but it didnt work.


Spoiler

 

"If a vegetarian eats vegetables,What the heck does a humanitarian eat?"

"I hear voices in my head, but I ignore them and continue on killing."

"You have forced me to raise the indifference warning to beige, it's a beige alert people. As with all beige alerts please prepare to think about the possibility of caring."

An optimist says that giving someone power DOESN'T immediately turn them into a sadist. A pessimist says that giving someone power doesn't IMMEDIATELY turn them into a sadist.

 

 

Share this post


Link to post
Share on other sites

I just started to try my hands on a screensaver, too, when I came here to look for inspiration and found this topic. Here is what I have got so far:

If StringLeft ( $CmdLineRaw, 2 ) = "/c" OR $CmdLineRaw = "" Then
    Run("config.exe")
ElseIf StringLeft ( $CmdLineRaw, 2 ) = "/p" Then
    Exit
ElseIf StringLeft ( $CmdLineRaw, 2 ) = "/s" Then
    Run("Screen saver execute.exe") 
EndIf

Share this post


Link to post
Share on other sites

Yay!!! I finally understand command line perameters!!! Thanks friend.

Ok, now I have another problem. I have edited the script for testing so that it will display msgbox's insted of running files, so that I could test to see if this was correct.

Eather I havr the wrong ideas, the script is incorrect, or windows is passing the script with no parimeters at all.

To see what I mean, compile the script with a .scr extention and rightclick the file, click configure. No matter what you click, you will allways get none.

I guess Right Click -> Configure doesn't throw any params. Since -c is the default action anyways for an scr (even when no params are used) you could just do this.

If $CMDLINE[0] = "" Then $mode=0

Also, just a recommendation, you can simplify the whole -c versus /c by using StringInstr()

If StringInstr($CmdLine[1],"c") > 0 Then
    $mode=0
ElseIf StringInstr($CmdLine[1],"s") > 0 Then
    $mode=1
ElseIf StringInstr($CmdLine[1],"p") > 0 Then
    $mode=2
EndIf

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0