[Feature Request] Command line parameter to execute code without script file

Propose new features and changes
stax76
Posts: 12
Joined: 20 Jan 2022, 10:07
Contact:

[Feature Request] Command line parameter to execute code without script file

04 Jan 2024, 03:05

PowerShell and all other shells I know have a command line parameter to run code without a script file. Command line power users use this feature frequently. It would be a useful feature if AutoHotkey would support it too.

Code: Select all

Desktop> bash -c 'echo foo bar'
foo bar
Desktop> powershell -command echo foo bar
foo
bar
Desktop> cmd /c echo foo bar
foo bar
Desktop>
https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_powershell_exe?view=powershell-5.1#parameters

https://tldp.org/LDP/abs/html/bash-options.html

https://ss64.com/nt/cmd.html0

[Mod edit: Moved topic from 'AutoHotkey Development'.]
lexikos
Posts: 9592
Joined: 30 Sep 2013, 04:07
Contact:

Re: [Feature Request] Command line parameter to execute code without script file

19 Jan 2024, 02:03

It is possible to execute code via stdin instead; e.g. echo MsgBox|AutoHotkey.exe *. This can be made more convenient with a batch script, shell function or alias.
User avatar
V2User
Posts: 195
Joined: 30 Apr 2021, 04:04

Re: [Feature Request] Command line parameter to execute code without script file

19 Jan 2024, 05:49

Currently, we can only execute code from a file in disk. But with this wish, we might execute code directly from a String in memory.
Therefore, after implementing this wish, performance might become much more faster, when we need to create a new AHK process. :wink:
User avatar
V2User
Posts: 195
Joined: 30 Apr 2021, 04:04

Re: [Feature Request] Command line parameter to execute code without script file

19 Jan 2024, 06:14

lexikos wrote:
19 Jan 2024, 06:03
@V2User, did you read my post?
Sorry, maybe I have some misunderstand of it. I'm not familiar with these and I guessed echo MsgBox|AutoHotkey.exe * would execute code from file in disk as well as other current methods. :think:
At least, currently, we are not able to create process in the run time of the current AHK process directly from memory. This is what I can only sure.
lexikos
Posts: 9592
Joined: 30 Sep 2013, 04:07
Contact:

Re: [Feature Request] Command line parameter to execute code without script file

19 Jan 2024, 06:50

What file? You can copy-paste my example into a command prompt (if AutoHotkey.exe is in the current directory). It goes directly in the command line. Isn't that the point of a command line parameter?

Running script code without writing it to a file on disk has been possible all along, even before stdin support. I demonstrated it 17 years ago.

At least, currently, we are not able to create process in the run time of the current AHK process directly from memory.
That made no sense.
User avatar
V2User
Posts: 195
Joined: 30 Apr 2021, 04:04

Re: [Feature Request] Command line parameter to execute code without script file

19 Jan 2024, 07:12

lexikos wrote:
19 Jan 2024, 06:50
demonstrated it 17 years ago.
Thank you. :+1: It's much useful to me. Much appreciated.

Return to “Wish List”

Who is online

Users browsing this forum: No registered users and 59 guests