Lurker News
Hello HN,

this is the first functional reimplementation of AutoHotkey [1] for Unix-like systems, as far as I am aware. Half the commands are still missing, but everything important is done, as I have worked a lot on it over the past two months. Converting scripts into stand alone binaries is also supported. Hope this will find some adoption eventually. :-) - This implementation focuses on v1.0-like classic syntax from 2004 (!). This is a significant subset of the popular current v1.1 syntax from Windows (AHK_L). The reason this does not (yet?) target the full Windows spec is how complex it is. Notably, there's also another ongoing project which targets v2 called KeySharp [2].
If you are not aware of what AHK is, it is an easy but capable scripting language for automation and Hotkeys, and all sorts of visual things like GUIs.
If you want to learn more, there plenty of info on the repo, the docs html, and there's an active AHK Discord too, and I am personally also checking the forums and HN of course.
[1] https://www.autohotkey.com/ [2] https://bitbucket.org/mfeemster/keysharp/

Comments (183) 43 threads

Earlier comments
yewenjie13 replies#
I have never used AHK before. Can someone please explain to me what _could_ it bring to the Linux world given that scripting is much easier in general?
michaelcampbell#
On Windows I use it as a text-expander. @ sans chevrons expands to my email address, and I have many of these.
tastyfreeze#
I use AHK to script interactions with a GUI application that I support but don't control the source or database. It allows me to script some repetitive tasks in the GUI and trigger them with a defined key sequence.
bcassedy#
I've used it pretty extensively in Windows to expand text, execute clicks on certain buttons in GUIs, execute clicks on specific coordinates on screen or within a window, and to combine all these things into complex macros.
BeetleB3 replies#
Here are a few things I've done in AHK on Windows:

1. Move cursor to the toolbar icon of an app, right click, navigate menus, and select an option (all with one keystroke).
2. Click a button in one program. Copy file. Switch to Excel. Switch to the right worksheet. Click a VBA button. Switch to another sheet. All with one keystroke.
3. With one keystroke, set certain settings in Visual Studio (via the menu) and run the debugger.
4. With a keystroke, sign out of Teams/Skype.
5. Launch screenshot program, present me with a dialog box asking for filename, and have it save the screenshot in a directory and provide me an Org-mode link to the saved file.
These are all "easy" in AHK. I never learned it well enough to do more advanced stuff.

BeefWellington1 reply#
You can do similar things with xdotool (actually a lot more complex things) but it's missing a good GUI-based recorder tool.
mkl1 reply#
xdotool does about a quarter of what AutoHotKey does, and even combined with sxhkd, Espanso, Autokey etc. still doesn't match up. xdotool doesn't do hotkeys itself, and doesn't work well being run with hotkeys involving modifiers (yes I'm aware of hacks involving getting xdotool to release modifier keys - I haven't succeeded getting them to work for anything nontrivial). AutoHotKey also does hotstrings (Espanso is the closest Linux equivalent I know, and doesn't work as well IME), app- or window-specific behaviour, and more.

Continue this thread — 1 reply

esrh2 replies#
AHK's prime utility seems like hacking optimizations on inefficient-for-power-users gui software.

It kind of makes sense then that this was made for and got popular on windows, because that OS is absolutely rife with annoying gui software written for the lowest common denominator of user.
Whenever i infrequently have to use windows I'm a bit shocked at the number of clicks you need to get anything done.

BeetleB3 replies#
OK, here's one for you. How would you automate a task in Firefox? Here's something I need to do often (to get around a bug in FF):

1. Press Ctrl P to get to the Print dialog 2. Scroll to "Print Using System Dialog" 3. Click on Page Setup. 4. Select 2 Pages per side. 5. Choose "Letter" for Paper Size 6. Click on "Print"
I can automate this using AHK on Windows. How would you do it on Linux? And how is running Firefox on Linux helping me any more than Windows?

Continue this thread — 3 replies

PurpleRamen#
> AHK's prime utility seems like hacking optimizations on inefficient-for-power-users gui software.

That's like saying shellscripts prime utility seems like hacking optimizations on inefficient-for-power-users cli software. Every poweruser has always demand for automation, independent of the interface, software and OS.
> because that OS is absolutely rife with annoying gui software written for the lowest common denominator of user.
And yet, Linux is even worse in that regard.

dustractor1 reply#
There are those pesky extra cmd windows that sometimes show up when one gui program has to use a subprocess to run cmd.exe to start another gui program. The only only only solution I found after trying purported solutions in visual basic, powershell, c++, python, etc... Somehow, AutoHotKey's code for finding invisible windows is better than even what's on the msdn site.
ComodoHacker1 reply#
Another solution to the 'flashing console' problem is to wrap cmd invocation into VBS script. It allows you to set that flag to hide console window.

Continue this thread — 1 reply

flarg1 reply#
It automates your desktop with a mini programming language that can be used to build desktop apps; but it's the text expansion capabilities that are highly prized, working across all desktop and web apps and saving you 100s of hours of typing.
flarg#
For sure it does but AHK has a wider user base
phil2942 replies#
It's a simple and valid question, but I'm afraid the answer is rather nuanced. Most things you do with AHK are also possible on Linux in general, but in a much more fragmented way. AHK (in its complete form) unifies most functionality of xbindkeys, xdotool, GUI creation (no common tool I am aware of), popups, wmctrl, unix tools like echo/cp/, assistive technology, window manager tools, grabc, and many more, out of which some aren't even possible without sophisticated programming like Hotstrings (auto-replace while typing), ImageSearch, StatusBarGetWait and all those things. It also ships with many common programming language features such as math operations, and brings its own equivalents to unix tools like FileCopy and FileAppend.

Then there's also AHK's ease of use, which also makes it appealing to non-programmers or beginners. Every piece of logic (even loops etc) is basically encapsulated in a single-word command instruction, almost like ASM, but for humans. You create GUIs with `Gui, add, button`, maximize windows with `WinMaximize Firefox`, hotkeys with `a::MsgBox You pressed a` and so on, and all of that with basically no code. I'd recommend you take a short look at the AHK documentation, such as the intro or alphabetical list of commands. It gives you an idea of what you can do with it.
Besides, the entire language is visually oriented (and so is this implementation of mine): You create, edit, run, reload, and (optionally) compile scripts usually not by using terminal, but by context menus. This makes it far more accessible for people migrating from Windows, apart from the fact that you can apply your acquired AHK skills from Windows.
Finally, I have found that the existing Linux automation-specific tools (which mostly boils down to xdotool) are, in comparison to Windows AHK, inferior. Getting Windows-like automation functionality on Linux is quite a task. The main difference is that very often, you just don't need Window or Hotkey automation on Linux, because most programs are CLI-first, thankfully.

llanowarelves1 reply#
Awesome comment.

It shows a failure of the "Unix Way" imo. Everyone hand-rolling their homebrew combination of 20 different tools together is sometimes not the best way to go.
We can look at Docker, Kubernetes, Dropbox(etc), desktop environments, and many other things to see that people greatly value almost the complete opposite approach, within some sweet-spot.

throw10920#
This is exactly right.

The reason that no nontrivial popular program exists written using shell scripts is because the Unix Way of gluing together separate programs just isn't a sustainable software development methodology that leads to nontrivial useful software.

aruggirello#
> GUI creation (no common tool I am aware of)

You can create simple GUIs straight from bash too - take a look at zenity (I'm aware it's not the only option BTW)

_nury1 reply#
For developer work, it can automate an entire sequence of GUI annoyances into a hotkey. I'm making this sequence up because I don't recall how it exactly went, but the volume of bizareness was about right. AHK helped me painlessly build JAR files in Eclipse. I'd hit F12 and:

AHK would pull up file menu, export menu, select java, type jar filename, hit next, select jar file, confirm overwrite, next, next, select seal the jar, yes overwrite, click that one random dialog button that's bizarrely not hotkey selectable, type main class as 'default.java', next, confirm, click finish. Click confirm again despite finish because GUI. And bam, another JAR file ready to test.

anthk1 reply#
Unix IDE's and OFC any good Unix editor (even scite) would make it trivial with a command.
_nury#
Well, you always get to weigh the effort of rebuilding a toolchain vs working within the existing clunky toolchain. However, I daresay that reimplementing everything that eclipse does for java is no trivial matter and for a day-long project, not worth my effort.

Though not everything can be done with different development tools and AHK is a versatile swiss army knife. It can also do things like hotkey to make any window stay on top, send window resize message to a runaway or disobedient window, or be hotkey window clicks for games. I use it in stormworks to make my own shortcuts to edit / wiring / mirror buttons since they're 54 inches apart, and hopefully this all shows where AHK's versatility shines.

checkyoursudo#
Back when I used Windows and played MMOs during the Vista or 7 days, I used AHK to do all sorts of grind-y tasks in-game. For example, grinding professions in SW:G to try to unlock Jedi (game might have survived if you could just pick Jedi classes from the start, just saying ...) and similar painful mechanics in most MMO(RPGs at least).

I did use PyUserInput/PyMouse to "play" Universal Paperclips one time on Linux. Similar, though not nearly as featured, to AHK.

airstrike#
Just to add to the list of very bespoke hotkeys, I have one to change the "default" text color of e-mail replies in outlook. If I press Win+A and the active window is part of outlook, it will go into File, Options, Mail, Stationery and Fonts, "Font" for replies, and open the color picker

Helpful when I'm trying to send inline responses in an otherwise busy thread with multiple colors... and then I can switch back to my default blue after that with the same keystroke

Continue this thread — 3 more replies

mathverse#
I like seeing languages like Crystal in the wild! Good job.
stavros5 replies#
I've been looking for something that can recognize the mute button in call software (Zoom, Meet, etc) and click it, but everything I've found seems to do image detection.

I understand that running in a browser makes things hard, but is there a better method? I guess I could write an extension for Meet and Jitsi, but Zoom would then be the odd one out.

voat1 reply#
Nut.js
grimgrin1 reply#
aka “nut.js is a desktop automation framework for Node.js that allows you to program your mouse and keyboard with JavaScript or TypeScript”

https://nutjs.dev/

zazaulola#
I know JavaScript pretty well too, but I prefer to write local automation in Bash. Why do you need such a twisted solution?
lalopalota1 reply#
Does image detection with "always show meeting controls" not work?
stavros1 reply#
It does, but at 5 fps and unacceptable CPU usage, sadly.
unicornhose2 replies#
…you only have to do detection when required though (after the hotkey is pressed). Curious about the architecture of the 5fps solution.

Continue this thread — 2 replies

stavros#
It's easy to globally mute on Linux, but that doesn't show the "you are muted" UI elements, and makes the UX a bit more confusing. I wanted something more explicit, which is hard.
jwrallie#
I know what you are asking is useful on its own, but Zoom support starting with the microphone muted, or even not joining the audio stream at all, check out these options: Settings->Audio->Mute my microphone when joining a meeting Settings->Audio->Automatically join audio by computer when joining a meeting

Load more comments