powershellautohotkeyprocess-substitution

Pass in a command string to AutoHotkey


I want to run a single AutoHotkey command. A script seems kindof overkill.

In bash and powershell, you can run a command by passing it in as a string to the shell:

pwsh -Command ls
bash -c ls

Is there a way to do this with AutoHotKey.exe? In the documentation, all I see is that you can pass the name of a script file to execute. If powershell supported process substitution <(ls), I could do

AutoHotKey.exe <(echo "ls")

But I don't think there's a way to do this in powershell.

Is there another way other than creating a complicated version of process substitution myself?


Solution

  • The linked docs state:

    [v1.1.17+]: Specify an asterisk (*) for the filename to read the script text from standard input (stdin). For an example, see ExecScript().

    For instance, from PowerShell:

    'MsgBox % "Hello, world."' | AutoHotKey.exe *