Skip to content

Instantly share code, notes, and snippets.

@pjeby
Last active July 23, 2026 17:12
Show Gist options
  • Select an option

  • Save pjeby/20c7d0ee91ce55dab2272d4b11213058 to your computer and use it in GitHub Desktop.

Select an option

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
#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