Sign in to follow this  
Followers 0
ca143508

Switches

4 posts in this topic

Hey Guys,

I have a script with different functions in it. What I would like to do is have a switch in it so that I can run my script from a specific function. At the moment when I run the exe version it goes in a loop until a certain system time is matched and then works it's way through the functions until the end of the script. However if I ran C:\myprog.exe /m (for example) it would skip the time check and run the rest of the functions. Is there such a way that autoit can do this?

Thanks heaps

Mike.

Share this post


Link to post
Share on other sites



Look at the help file under "command line parameters"

excerpt:

The special array $CmdLine is initialized with the command line parameters passed in to your AutoIt script. Note the scriptname is not classed as a parameter; get this information with @ScriptName instead. A parameter that contains spaces must be surrounded by "double quotes". Compiled scripts accept command line parameters in the same way.

$CmdLine[0]is number of parameters

$CmdLine[1] is param 1 (after the script name)

$CmdLine[2] is param 2 etc

Share this post


Link to post
Share on other sites

Hey Guys,

I have a script with different functions in it. What I would like to do is have a switch in it so that I can run my script from a specific function. At the moment when I run the exe version it goes in a loop until a certain system time is matched and then works it's way through the functions until the end of the script. However if I ran C:\myprog.exe /m (for example) it would skip the time check and run the rest of the functions. Is there such a way that autoit can do this?

Thanks heaps

Mike.

Check out Command Line Parameters in the help file. If you script is compiled and run as: C:\myprog.exe /m, then $CmdLine[0] = 1 (count of parameters), and $CmdLine[1] = "/m". So you get:

If $CmdLine[0] = 0
     ; No command line parameters
     MsgBox(64, "MyProg", "No commandline parameters used.")
ElseIf $CmdLine[1] = "/m" Then
     ; /m parameter was used
     MsgBox(64, "MyProg", "Switch 'm' was used.")
Else
     MsgBox(16, "Error!", "Invalid commandline argument, not '/m'.")
EndIf

:D


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

Look at the help file under "command line parameters"

excerpt:

Thanks for this. I was just having a bit of trouble getting my head around the help file explanation. Appreciate your help.

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