Last active
July 23, 2026 17:12
-
-
Save pjeby/20c7d0ee91ce55dab2272d4b11213058 to your computer and use it in GitHub Desktop.
A script that works as a cygwin shell command but is also an autohotkey v2 script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #Requires AutoHotkey v2.0 | |
| #SingleInstance Force | |
| declare "x" ; exec autohotkey "$(cygpath -w "$0")" "$@" | |
| /* | |
| The above is a valid autohotkey script preamble - any directives are | |
| placed at the top and read by bash as comments. (We can't use a | |
| shebang because it makes AHK barf, so we're relying on text files | |
| being shell scripts by default.) | |
| So the declare is read as a shell command before a second shell | |
| command to exec the script via autohotkey.exe. But AHK reads it | |
| as a function call to declare("x"), followed by a comment. The | |
| script just needs to have an empty function definition for declare() | |
| somewhere in it (as shown below), and then the rest of the script | |
| is pure AHK. | |
| */ | |
| declare(x) { | |
| } | |
| ; Optional: syntax declaration for gist/vscode/etc. to see this as an ahk file | |
| ; ex: set ft=ahk : |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment