Notes re automation and replacing Windows' AutoHotkey  [Solved]

Here is where you can post tips and tricks to share with other users of MX. Do not ask for help in this Forum.
Message
Author
thomasl

Notes re automation and replacing Windows' AutoHotkey

#1 Post by thomasl »

(Those who haven't used AutoHotkey (AHK) under Windows (or are not missing it under Linux) can ignore this post... although automating things is a Good Thing for every system, IMHO.)

Since I have switched to Linux, replacing AHK with equivalent Linux apps has been a sort of Holy Grail for me. AHK is a Swiss-army-knife-type utility for Windows and there is just no replacement for Linux. Sure, Autokey is always trotted out as a replacement but it is a) not nearly as powerful as AHK and b) a lot less reliable (not to say buggy). Nevertheless, there are some things Autokey does well most of the time, not least global hotkeys and system-wide menus both of which can execute user-written Python scripts. There's a significant learning curve but then again there's also a significant learning curve for AHK :crossfingers:

Autokey is in the repos although the latest 0.95.10 (test repo) has a couple severe bugs that are (mostly) fixed in git head.

One thing Autokey can't do is using mouse buttons as triggers (it can replay them though). Enter a second utility: xbindkeys (in the repos) can be used to start programs, scripts etc for any keypress or keypress combination... including mouse buttons (also all non-standard mouse buttons so long as X recognises them). In the long run I will try to replace Autokey with xbindkeys.

Number three is devilspie2 (also in the repos). This small utility can be used to position and size all sorts of windows on the current desktop or move them to other workspaces. It can also trigger arbitrary other actions whenever a window is created. Again, there's a learning curve.

Last but not least there's something I discovered just a few weeks ago: espanso. This is a superb utility to create hotstrings, next to hotkeys one of the seminal strengths of AHK. (A hotkey is just a systemwide key combination that simply triggers an action whereas a hotstring is a (normally short) typed string that is dynamically expanded to another string or triggers some other action.) Espanso does this fast and, most importantly, very reliably. This is a real gem AFAIC since I had a collection of about 500 hotstrings under Windows for all sorts of things... email addies, pathnames, login names, some throwaway passwords, account nos... you name it. Espanso handles all that and much more gracefully. It is also not that hard to use, at least for the basic hotstring capability. Absolutely recommended.

So... these four utilities between them can almost completely replace AHK under Linux , at least for my use cases. It is not exactly pretty, it requires some perseverance, but it works. YMMV.

richaardvark
Posts: 18
Joined: Fri Jun 05, 2020 9:01 pm

Re: Notes re automation and replacing Windows' AutoHotkey  [Solved]

#2 Post by richaardvark »

There's also of course xdotool, which can control windows/simulates mouse clicks/simulates keyboard text entry.

If you like to create GUIs for your AHK scripts, YAD is a very versatile and wonderful tool.

openvuvuzela
Posts: 14
Joined: Sun Apr 05, 2020 3:55 pm

Re: Notes re automation and replacing Windows' AutoHotkey

#3 Post by openvuvuzela »

create GUIs for your AHK scripts, YAD is a very versatile and wonderful tool.
Create LINUX GUIs for your AHK scripts whit YAD? I think that I'm not understanding
Do NOT contact using email. I have lost it!

thomasl

Re: Notes re automation and replacing Windows' AutoHotkey

#4 Post by thomasl »

Some further remarks about my attempts re automation and replacing AutoHotkey.

I have never been very happy with AutoKey. It is not as as stable as it should be (IMHO and YMMV) and I also found its GUI pretty distracting. So I have finally bitten the bullet and thrown it off my system.

All hotkeys (both for keyboard and mouse hotkeys) are now done with xbindkeys, works very well and is rock-solid. This is mostly used for starting programs or presenting a plethora of menus (eg a list of my email addys, clipboard commands, window resizing options etc etc).

Hotstring expansion is done with espanso (link in first post), also rock solid. This is used to expand stuff like "tc#" to "/home/thomasl/.config/" or "ulp#" to "/usr/lib/python3/dist-packages/".

Both hotkeys and hotstrings work system-wide, in all programs that accept keyboard input.

Sending keys and strings, manipulating windows and desktop etc is done with xdotool and devilspie2.

Last but not least, all menus (most of which are started via a hotkey) are displayed with rofi (in the repos), in its dmenu mode. This is another superb tool that has finally enabled me to get rid of AutoKey. I will add a real-world example in a further post when I have cleaned up things a little. :snail:

So this collection of tools does the job, though not as nicely within a single package as AutoHotkey... configuring things is a bit more involved at first but of course this has to be done only once. But OTOH there is more flexibility as the various tools and further utilities (ie small python helpers or shell scripts) can be endlessly combined. :happy:

LionelZaylan
Posts: 97
Joined: Sat May 22, 2021 12:37 am

Re: Notes re automation and replacing Windows' AutoHotkey

#5 Post by LionelZaylan »

openvuvuzela wrote: Tue Feb 09, 2021 5:52 pm
create GUIs for your AHK scripts, YAD is a very versatile and wonderful tool.
Create LINUX GUIs for your AHK scripts whit YAD? I think that I'm not understanding
The source code of Adblock ( antiX advert blocker ) is an excellent example of YAD to make GUI scripts

Code: Select all

 less $(which block-advert.sh) 
on MX/antiX
or go to https://gitlab.com/antiX-Linux/advert- ... advert.sh

Post Reply

Return to “Tips & Tricks by users (not for help)”