Jump to content

Recommended Posts


Posted

$CmdLine

you have to make the instructions in the script itself

ie: if $CmdLine[1] = "/?" then msgbox("help")

and the variable i are separated by spaces

ie: autoittest.exe log user

this would make $CmdLine[1] = "log"

and $CmdLine[2] = "user"

search the manual im sure theres some help there.

Posted

A simple example

If $CMDLINE[0] = 2 Then
$vanilla = $CMDLINE[1]
$chocolate = $CMDLINE[2]
MsgBox(0x40000, 'CMDLINE', $vanilla & @CRLF & $chocolate)
EndIf

Posted
If $CMDLINE[0] And $CMDLINE[1] = '/?' Then
MsgBox(0x40000, 'Help', 'Not a problem;)')
Exit
EndIf

  • 2 months later...
Posted

I've written an AutoIt script to make Nero portable. It works great, except for one problem. I need to have the script (compiled of course) pass a single parameter (/w) to the Nero executable via shortcut. This will allow me to select Nero Express without having to go through Nero's main interface, or if I use a shortcut for Nero.exe, it loads the main interface.

I've spent literally hours searching the AutoIt forum and help file, google and here without results. There is not one clear explanation of how to pass a parameter easily.

Here's the line that runs Nero.

RunWait(@ScriptDir & "\Nero\Nero.exe")

It should be as simple as adding $1 or %1 like this (like every other language on the planet):

RunWait(@ScriptDir & "\Nero\Nero.exe" & $1)

But of course that doesn't work. The genius that wrote AutoIt removed that nice feature from the latest version.

I don't understand $CmdLine at all. It makes no sense.

Posted
It should be as simple as adding $1 or %1 like this (like every other language on the planet)

(.../...)

I don't understand $CmdLine at all. It makes no sense.

:wacko:

$CmdLine[0] lets you test the number or space-delimited arguments

$CmdLine (where i is an integer lower or equal to $CmdLine[0]) returns you the i-th argument.

In other words : your $1 or %1 becomes $CmdLine[1] :rolleyes:

Thus, your script becomes (this is a very bad-written sample) :

If Not $CmdLine[0] Then
RunWait(@ScriptDir & "\Nero\Nero.exe")
Else
RunWait(@ScriptDir & "\Nero\Nero.exe" & " " & $CmdLine[1])
EndIf

As you can see, the genius who wrote $CmdLine thing forces you to write error-trapping code...

++

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