shebang-like hint to ensure correct AHK v1/v2 detection? Topic is solved

Propose new features and changes
benbrown
Posts: 5
Joined: 05 Jun 2019, 04:25

shebang-like hint to ensure correct AHK v1/v2 detection?

Post by benbrown » 08 Mar 2023, 09:04

Problem:
  • AHK can only guess at whether to run a script as V1 or V2.
  • The official AHK2 release announcement states that "The Launcher will run the appropriate version of AHK based on its attempt at automatic detection and your settings." (emphasis mine)
Suggestion:
  • Linux shell scripts typically begin with a shebang line that explicitly states what execution mehtod to use.
  • If we add the same kind of shebang to AHK scripts, then we can actively tell AHK which version to use.
  • Incidentally, I think the standard shebang symbol #! is directly compatible with AHK syntax.
  • The AHK settings can specify whether the shebang will be honored = see dummy screenshot below.
Effect and benefit:
  • Any script that has a shebang will be guaranteed to run with the AHK version the author intended.
  • Any script without a shebang will remain subject to AHK auto-detection.
image.png
image.png (17.67 KiB) Viewed 1226 times

User avatar
boiler
Posts: 16767
Joined: 21 Dec 2014, 02:44

Re: shebang-like hint to ensure correct AHK v1/v2 detection?  Topic is solved

Post by boiler » 08 Mar 2023, 09:10

benbrown wrote: AHK can only guess at whether to run a script as V1 or V2.
That is not a correct statement. A mechanism like you described already exists. See #Requires (v1) and #Requires (v2).

User avatar
Animan8000
Posts: 56
Joined: 11 May 2022, 05:00
Contact:

Re: shebang-like hint to ensure correct AHK v1/v2 detection?

Post by Animan8000 » 10 Mar 2023, 10:55

Yea as already mentioned, Requires directive is the way to go and in my opinion there's never a reason not to use it. The directive allows to avoid false version detections, gives clarity to the user what version the script is supposed to be for and additionally a small performance benefit during startup by not having to RegEx every little thing.

Post Reply

Return to “Wish List”