Jump to content

Command line options


KXP
 Share

Recommended Posts

Hi.

I need to make a console script which will be able to accept some command line options as its input and then compile it to exe with Aut2Exe (the 2nd part doesn't make any problems).

But I have no idea how to do it.

Please help me guys.

Thanks.

Edited by KXP
Link to comment
Share on other sites

Something like this ?

If $Cmdline[0] Then
    For $_I = 1 To $Cmdline[0]
        Switch $Cmdline[$_I]
            Case '/?','-?','/help','-help'
                Exit MsgBox (0x40000, StringTrimRight ( @ScriptName, 4 ) & ' Help', 'Switches are:' & @LF _
                        & @LF & '/extract' _
                        & @LF & @TAB & 'Extract files to current directory' _
                        & @LF & '/x' _
                        & @LF & @TAB & '' _
                        & @LF & '/y' _
                        & @LF & @TAB & '' _
                        & @LF & '/z' _
                        & @LF & @TAB & '')
            Case '/x'

            Case '/y'

            Case '/z'

            Case Else
                Exit MsgBox ( 262144, 'Incorrect switch used', 'Command used:' & @LF & $CmdlineRaw & @LF & @LF & 'Use /? for the Switches available.' )
        EndSwitch
    Next
EndIf
Edited by wakillon

AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Link to comment
Share on other sites

Something like this ?

If $Cmdline[0] Then
    For $_I = 1 To $Cmdline[0]
        Switch $Cmdline[$_I]
            Case '/?','-?','/help','-help'
                Exit MsgBox (0x40000, StringTrimRight ( @ScriptName, 4 ) & ' Help', 'Switches are:' & @LF _
                        & @LF & '/extract' _
                        & @LF & @TAB & 'Extract files to current directory' _
                        & @LF & '/x' _
                        & @LF & @TAB & '' _
                        & @LF & '/y' _
                        & @LF & @TAB & '' _
                        & @LF & '/z' _
                        & @LF & @TAB & '')
            Case '/x'

            Case '/y'

            Case '/z'

            Case Else
                Exit MsgBox ( 262144, 'Incorrect switch used', 'Command used:' & @LF & $CmdlineRaw & @LF & @LF & 'Use /? for the Switches available.' )
        EndSwitch
    Next
EndIf

Not trying to hijack this thread, but is it a typo or did you mean to code it like this and if so out of curiosity why?

Exit MsgBox ( 262144, 'Incorrect switch used', 'Command used:' & @LF & $CmdlineRaw & @LF & @LF & 'Use /? for the Switches available.' )
Edited by LurchMan

Dating a girl is just like writing software. Everything's going to work just fine in the testing lab (dating), but as soon as you have contract with a customer (marriage), then your program (life) is going to be facing new situations you never expected. You'll be forced to patch the code (admit you're wrong) and then the code (wife) will just end up all bloated and unmaintainable in the end.

Link to comment
Share on other sites

Not trying to hijack this thread, but is it a typo or did you mean to code it like this and if so out of curiosity why?

Exit MsgBox ( 262144, 'Incorrect switch used', 'Command used:' & @LF & $CmdlineRaw & @LF & @LF & 'Use /? for the Switches available.' )

Don't worry about this, it's just to save space ! Posted Image

AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Link to comment
Share on other sites

wakillon, Thank you very much!

Can I ask 1 more question?

I'm launching an application in console using AutoIt (Run function).

In some cases the application outputs a prompt to the console and if this prompt appears the script should send some data (input a string & press enter, I think could be done with ControlSend function).

So how can I wait for that prompt in my script?

I know this prompt and can specify it.

Thanks a lot.

Edited by KXP
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...