Jump to content

Recommended Posts

Posted

Hi guys,

Id like to learn how for example, in the following code:

If $CmdLine[0] = 0 Then
    MsgBox(64, "Result", "No parameter was entered!")
    Exit
EndIf
MsgBox(64, "Entry", $CmdLine[1])

You can add help information for the user, displayed at the command line.

For example, if at a command line, the user enters:

c:\test.exe

A msgbox will appear saying that "no parameter was entered".

What I would like is, if no parameter was entered, or the user types:

c:\test.exe /?

Then information will appear in the command window stating application usage, eg:

Usage: test.exe param1

Any help greatly appreciated.

Posted

Hi,compile and try

If $CmdLine[0] = 0 Then
    MsgBox(64, "Result", "No parameter was entered!")
    Exit
Else
    Switch $CmdLine[1]
        Case "/?"
            MsgBox(64, "Help", "Usage: " & @AutoItExe & " /param1")
        Case "/param1"
            MsgBox(64, "param1", "1st parameter received: "  & $CmdLine[1])
            If $CmdLine[0] > 1 Then ContinueCase
        Case Else
            MsgBox(64, "Commandline Raw", "$CmdLineRaw: "  & $CmdLineRaw)
    EndSwitch
EndIf

Cheers

Posted

Hi Smashly, thanks so much for your kind help.

That works Smashly, but what I really wanted was to write the output not to a msgbox, but to a command line prompt.

I tried the following:

If $CmdLine[0] = 0 Then
    MsgBox(64, "Result", "No parameter was entered!")
    Exit
Else
    Switch $CmdLine[1]
        Case "/?"
            ;MsgBox(64, "Help", "Usage: " & @AutoItExe & " /param1")
            ConsoleWrite ("sdf")
        Case "/param1"
            MsgBox(64, "param1", "1st parameter received: "  & $CmdLine[1])
            If $CmdLine[0] > 1 Then ContinueCase
        Case Else
           ; MsgBox(64, "Commandline Raw", "$CmdLineRaw: "  & $CmdLineRaw)
            consolewrite ("nos")
    EndSwitch
EndIf

And this worked in Scite, but not at a prompt.

Posted

Hi guys,

I just did some research on ConsoleWrite, where it said that:

"This does not write to a DOS console unless the script is compiled as a console application."

http://www.autoitscript.com/autoit3/docs/functions/ConsoleWrite.htm

So, I compiled it with CUI instead of GUI.exe and it worked.

I just thought I would put it here for others to see.

Thanks for your help.

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
  • Recently Browsing   0 members

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