I'd like to run the AHK script with arguments, like:
AutoHotkeyU64 file.ahk arg1 arg2
Then access these variables as part of the script, e.g.
MsgBox, %arg1%, %arg2%
How this can be achieved?
I'd like to run the AHK script with arguments, like:
AutoHotkeyU64 file.ahk arg1 arg2
Then access these variables as part of the script, e.g.
MsgBox, %arg1%, %arg2%
How this can be achieved?
The command line parameters are stored in the variables %1%, %2%, and so on. So for example:
MsgBox, %1%, %2%
Since version v1.1.27+, input parameters are stored as an array in the built-in variable A_Args as an array.
Here is the example:
for n, param in A_Args ; For each parameter:
{
MsgBox Parameter number %n% is %param%.
}
Legacy: The command line parameters are also stored in the variables
%1%,%2%, and so on, as in versions prior to [v1.1.27]. In addition,%0%contains the number of parameters passed (0 if none). However, these variables cannot be referenced directly in an expression because they would be seen as numbers rather than variables.
This works for me:
In AutoHotkey, %1%, %2% and so on are the command line arguements that have been given.
Lets say we have a script called script.ahk, and inside of that script we have MsgBox, %1%
if I were to type script.ahk hey, we would get a messagebox with hey in it.
Demo Screenshot
Hopefully that helps :-)