Jump to content

How to make your script take in parameters?


Recommended Posts

A while back I ran across a UDF (and have been trying to find it again but cannot) that allowed your autoit executable to take in a parameter. This particular UDF was to hide your source code inside your executable. It worked like this...

Double click your executable MyProgram.exe and it works like normal.

Run your executable by passing a switch like this:

MyProgram.exe -extractsourcecode

and that would run FileInstall of your embedded .au3 to a predetermined location (desktop).

I'm not trying to embed source code. I want to be able to make my executable to act differently with different switches passed to it. Any ideas? Thanks!

#include <ByteMe.au3>

Link to comment
Share on other sites

Thank you for pointing me in the right direction. It took me a little bit to figure it out, so here's an example script I just wrote to help others who may have trouble figuring it out.

If $CmdLineRaw = "-option1" Then
    MsgBox (0, "", "Your chose the first option")
ElseIf $CmdLineRaw = "-option2" Then
    MsgBox (0, "", "The second option was chosen.")
Else
    MsgBox (0, "", "You either used a parameter that is not recognized or ran the executable directly.")
EndIf

Basically, $CmdLineRaw is a built in function that retrieves what typed in after the script/executable's name.

Thanks again for your help.

#include <ByteMe.au3>

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...