Skip to content
View in the app

A better way to browse. Learn more.

MSFN

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Howto pass a parameter to AutoIT?

Featured Replies

Is it possible to call an AutoIT script with parameters?

I think, that I read the manual very extensive, but didn't find a way

Thanks in advance


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

A simple example

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

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

  • 2 months later...

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.

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

++

Thank you very much, Delprat. It may be badly coded but it works great. It's also the best explanation I've seen yet.

Create an account or sign in to comment

Recently Browsing 0

  • No registered users viewing this page.

Account

Navigation

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.