News for hackers. Stuff that matters.
Re:Show HN: AutoHotkey for Linux by BeetleB on Tuesday August 30, 2022 @03:57PM (#32654347)
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.

Re:Show HN: AutoHotkey for Linux by esrh on Tuesday August 30, 2022 @08:27PM (#32656889)
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.

Re:Show HN: AutoHotkey for Linux by BeetleB on Wednesday August 31, 2022 @12:45AM (#32658463)
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?

Re:Show HN: AutoHotkey for Linux by gjadi on Wednesday August 31, 2022 @03:47AM (#32659494)
I don't have an answer, but I've a question :P

How do you trigger the behavior? Is it bound to a key or is there a different way to trigger the action?

For example, I'm an emacs user and though I remember a lot of bindings, I also use heavily helm-M-x which provides fuzzy completion on command name.

For example, I may not remember all org-mode shortcuts, but I can do:

M-x org subtree

And I'll get a list of all org-mode commands on subtrees.

(I've never used AHK.)

Re:Show HN: AutoHotkey for Linux by PurpleRamen on Wednesday August 31, 2022 @07:31AM (#32660822)
> 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"

How exactly does this work? Are you just sending a bunch of shortcuts? Or does autohotkey really understand when it reached "Print Using System Dialog" and which button has "Page Setup"?

Re:Show HN: AutoHotkey for Linux by ridgered4 on Wednesday August 31, 2022 @08:34AM (#32661269)
You might just send all the expected commands in sequence and be fine, but that can be unreliable. Autohotkey can see the text contents of many dialogs and other windows components, which can be parsed and reacted too by the script. And it has functions for sending mouse clicks and keyboard commands, as well as directly editing controls, activating/minimizing/maximizing windows, etc. Unfortunately, I've found many more modern UI frameworks used in newer software have less that 'clues' that can be seen. But Autohotkey does have an image matching function that works well in a lot of cases when the traditional way fails.
Re:Show HN: AutoHotkey for Linux by PurpleRamen on Wednesday August 31, 2022 @07:27AM (#32660784)
> 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.

Re:Show HN: AutoHotkey for Linux by dustractor on Wednesday August 31, 2022 @12:18AM (#32658321)
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.
Re:Show HN: AutoHotkey for Linux by ComodoHacker on Wednesday August 31, 2022 @01:58AM (#32658891)
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.
Re:Show HN: AutoHotkey for Linux by Jaruzel on Wednesday August 31, 2022 @02:52AM (#32659196)
There's also a few RunHidden.exe type tools out there, as it's just a ShellExecute WinAPI call.
Re:Show HN: AutoHotkey for Linux by BeefWellington on Tuesday August 30, 2022 @04:01PM (#32654377)
You can do similar things with xdotool (actually a lot more complex things) but it's missing a good GUI-based recorder tool.
Re:Show HN: AutoHotkey for Linux by mkl on Tuesday August 30, 2022 @05:40PM (#32655502)
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.
Re:Show HN: AutoHotkey for Linux by BeefWellington on Tuesday August 30, 2022 @07:31PM (#32656524)
> xdotool does about a quarter of what AutoHotKey does, and even combined with sxhkd, Espanso, Autokey etc. still doesn't match up.

That may be true of AutoHotKey on Windows but we're talking about a Linux port here where some of the features straight up don't work or don't add anything that didn't already exist in Linux.

> xdotool doesn't do hotkeys itself, and doesn't work well being run with hotkeys involving modifiers

It doesn't do those things because it doesn't need to on any version of KDE or Gnome (or probably anything else) since about 1998, possibly earlier though my memory gets foggy beyond that point.

> AutoHotKey also does hotstrings (Espanso is the closest Linux equivalent I know, and doesn't work as well IME)

Espanso and AHK probably suffer the same fate, given this line from the AHK for Linux Documentation:

> Hotstrings don't work in some applications. Not sure if this is fixable (help needed!). The only reliable alternative is using Hotkeys.

> app- or window-specific behaviour, and more.

You can absolutely do app- and window-specific things with xdotool. It merely requires adding some steps to detect the window or process, which is identical to AHK's approach if you're just writing scripts.

The best thing this port has going for it is that it has a great UI that people are already familiar with and in spite of its shortcomings as a port it is worth checking out.

I'd love if someone spent the time to develop something like this into a script generator for xdotool that could do things like recording mouse movements, etc.

Maybe a wayland-ized version can support hotstrings and the other warty edge cases that don't work on Linux the way they do on Windows.