Draygoes Posted March 11, 2008 Share Posted March 11, 2008 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. Link to comment Share on other sites More sharing options...
spudw2k Posted March 11, 2008 Share Posted March 11, 2008 (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 March 11, 2008 by spudw2k Spoiler Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX BuilderMisc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retreive SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose ArrayProjects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalcCool Stuff: AutoItObject UDF ◊ Extract Icon From Proc ◊ GuiCtrlFontRotate ◊ Hex Edit Funcs ◊ Run binary ◊ Service_UDF Link to comment Share on other sites More sharing options...
Draygoes Posted March 11, 2008 Author Share Posted March 11, 2008 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"):EndIfError: "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. Link to comment Share on other sites More sharing options...
DjDeep00 Posted March 11, 2008 Share Posted March 11, 2008 @draygoes...Look in the help file for "Command Line Parameters"... Link to comment Share on other sites More sharing options...
spudw2k Posted March 11, 2008 Share Posted March 11, 2008 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? Spoiler Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX BuilderMisc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retreive SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose ArrayProjects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalcCool Stuff: AutoItObject UDF ◊ Extract Icon From Proc ◊ GuiCtrlFontRotate ◊ Hex Edit Funcs ◊ Run binary ◊ Service_UDF Link to comment Share on other sites More sharing options...
Draygoes Posted March 12, 2008 Author Share Posted March 12, 2008 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. Link to comment Share on other sites More sharing options...
Draygoes Posted March 12, 2008 Author Share Posted March 12, 2008 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. Link to comment Share on other sites More sharing options...
DjDeep00 Posted March 12, 2008 Share Posted March 12, 2008 (edited) @draygoes..Try this... expandcollapse popup#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 March 12, 2008 by DjDeep00 Link to comment Share on other sites More sharing options...
Draygoes Posted March 13, 2008 Author Share Posted March 13, 2008 (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: expandcollapse popup#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 March 13, 2008 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. Link to comment Share on other sites More sharing options...
rasim Posted March 13, 2008 Share Posted March 13, 2008 Run from cmd console withs -s param. Works for me. Link to comment Share on other sites More sharing options...
Draygoes Posted March 13, 2008 Author Share Posted March 13, 2008 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. Link to comment Share on other sites More sharing options...
ABlock Posted March 13, 2008 Share Posted March 13, 2008 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 Link to comment Share on other sites More sharing options...
spudw2k Posted March 13, 2008 Share Posted March 13, 2008 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 Spoiler Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX BuilderMisc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retreive SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose ArrayProjects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalcCool Stuff: AutoItObject UDF ◊ Extract Icon From Proc ◊ GuiCtrlFontRotate ◊ Hex Edit Funcs ◊ Run binary ◊ Service_UDF Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now