Jump to content

How to show help of a script in Command Line


Recommended Posts

Hi I have made a script with AutoIT and I want to launch Myscript /help on command Line, and as a result I Want to show a quick help of my script.

How to do this ?

Easiest way if you only want one command line switch:

If $CmdLine[1] == "/help" Then

Msgbox(0,"","some info")

Exit

EndIf

The above example does only work if you pass the help parameter as the first parameter.

Take a look at the documentation for command line switches. Everything is perfectly explained there.

You can fool some of the people all of the time, and all of the people some of the time, but you can not fool all of the people all of the time. Abraham Lincoln - http://www.ae911truth.org/ - http://www.freedocumentaries.org/
Link to comment
Share on other sites

Look for "Command Line Parameters" in the help file. That should point you in the right direction.

Hummm... ???

I Don't understand, in "Command Line parameters" that explain how to compile my script in command line !

That's not I Want to do !

When I type Myscript /help on command line, that shows a litte text to help users of my script

You understand ?

Link to comment
Share on other sites

Re-read that section:

Command Line Parameters

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

...

$CmdLine[$CmdLine[0]] is one way to get the last parameter...

So if your script is run like this:

AutoIt3.exe myscript.au3 param1 "this is another param"

$CmdLine[0] equals... 2

$CmdLine[1] equals... param1

$CmdLine[2] equals... this is another param

@ScriptName equals... myscript.au3

In addition to $CmdLine there is a variable called $CmdLineRaw that contains the entire command line unsplit, so for the above example:

$CmdLineRaw equals... myscript.au3 param1 "this is another param"

If the script was compiled it would have been run like this:

myscript.exe param1 "this is another param"

$CmdLineRaw equals... param1 "this is another param"

Note that $CmdLineRaw just return the parameters.

Note : only 63 parameters can be return by $CmdLine[...], but $CmdLineRaw will always returns the entire command line.

Edited by DarkMatter

[sub]Quantum mechanics: The dreams stuff is made of[/sub]

Link to comment
Share on other sites

Hummm... ???

I Don't understand, in "Command Line parameters" that explain how to compile my script in command line !

That's not I Want to do !

When I type Myscript /help on command line, that shows a litte text to help users of my script

You understand ?

Have you even read my post? Isn't that exactly what you want?! You can just copy my code, change the "some info" text and be happy!

You can fool some of the people all of the time, and all of the people some of the time, but you can not fool all of the people all of the time. Abraham Lincoln - http://www.ae911truth.org/ - http://www.freedocumentaries.org/
Link to comment
Share on other sites

No you idiots. The OP is wanting output to a console.

AutoIt is, when compiled normally, a Windows application. It doesn't connect to the console window unless you do some weird fiddling by tracking down the spawning process and attaching to its console.

wtf is wrong with you?

You can fool some of the people all of the time, and all of the people some of the time, but you can not fool all of the people all of the time. Abraham Lincoln - http://www.ae911truth.org/ - http://www.freedocumentaries.org/
Link to comment
Share on other sites

Hey potitpanda,

I guess you quoted my post cause that was the answer to your question, right?

Glad I could you :D

@Richard

Who's the idiot now? I wouldn't be so offensive, since we all are just trying to help each other!! Thank you!

You can fool some of the people all of the time, and all of the people some of the time, but you can not fool all of the people all of the time. Abraham Lincoln - http://www.ae911truth.org/ - http://www.freedocumentaries.org/
Link to comment
Share on other sites

This line affects the compiler, to make your app a Command Prompt Console app instead of a windowed app, I think:

#AutoIt3Wrapper_Change2CUI=y

You should expect this to work only if SciTe4AutoIt3 is installed, and only then after compiling the script. You should also expect that your app then can't have a GUI to it - I think - and this is what young RichardRobertson the no-idiot-whatever was trying to describe, howeverso politely.

And yes, we do need both mojo and dark matter - there has been some question about squirrels.

Edit: Striken text as per RichardRobertson

Edited by Squirrely1

Das Häschen benutzt Radar

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...