welcome to AutoKey, the free desktop automation utility for Linux. Do you use templates many times, repeated keystrokes or other repetitive tasks? If so, AutoKey is a great toolkit you don't want to miss out on.
What is it AutoKey?
Let's say you often type your email address or your postal address. It can be a bit frustrating having to type it all the time. Let AutoKey do it for you! All you have to do is associate a keyboard shortcut, a set of keystroke events, with a particular text blurb.
Another easy-to-configure feature is keyboard automation. AutoKey supports multiple key events, how to press the cursor left or right (the left and right arrow on the keyboard). To include this in your text blurb, all you have to do is use a little command that represents what you need to do:
In this sequence, we insert (as text) the code
HTML tag and then press the left
key seven times. This is very useful when you are developing HTML in a text editor and would like to quickly insert a code tag and return to where the code started (first code
label), and before the code block ends (second label, /code
). In other words, the seven left
the presses take us very well inside the ><
brackets.
We can also automate the filling of forms by inserting tabs, etc.
Sadly, there are some minor issues with the AutoKey program you should know. In Ubuntu 20.04.1 and using dpkg based installation, AutoKey may fail when trying to record a macro using the keyboard / mouse (Tools> Record Keyboard / mouse). In general terms, this functionality is not required for the purposes described in this guide.
Another problem is that AutoKey is somewhat complex to configure the first time, unless you have a guide like this to follow. Especially the opportunity to award keyboard shortcuts (abbreviations and hotkeys) to folders, as well as ‘phrases’ individual (think of this term as actual keyboard mappings to text blurs).
Finally, AutoKey, at least in Ubuntu 20.04.1, sometimes it does not respond to a keyboard sequence for which you have programmed it. An easy solution to this problem is to click on the AutoKey icon in the dock to bring it to the foreground and click on it.. You will see that if you go back to your workspace, key sequences will work again.
Even with these shortcomings, that can be resolved in due time, AutoKey is a must-have tool. Not having to type the address over and over again, press only two or three keys to paste in your email (keystrokes are automatically removed) and the ability to have complete document templates at the price of a few keys and a mouse click (to confirm the keyboard sequence), son invaluables.
installing AutoKey
This guide assumes you already have AutoKey up and running on your system.. If you haven't installed it yet, there are detailed instructions on the AutoKey project page on GitHub for various operating systems:
For Ubuntu users, Mint and other Debian-based operating systems, see Debian and derivatives.
You can also try: sudo apt install autokey-gtk
Para Arch, see Arch AutoKey Installation, and for Gentoo see Gentoo AutoKey Installation
Additionally you can install AutoKey using Python pip, see pip-based installation
If you already have an existing AutoKey installation, is essential remove it first. AND, before doing it, you may want to backup your configuration to ~/.config/autokey
.
Set up AutoKey
Once you have the AutoKey setup, open it and you should see the main interface:
As you can see, I already have some AutoKey configuration. AutoKey has many features, including a full scripting interface:
The first thing you'll want to do is set the preferences. Click Edit> Preferences. You will be presented with the next window:
We mark the first 3 options for (1) make sure AutoKey starts on startup, (2) Auto-save changes and (3) to display a notification icon on the taskbar, which in Ubuntu is presented as follows:
You can use this notification icon to quickly use some items without having to use keyboard shortcuts, as well as open the application directly.
Using AutoKey: Keyboard shortcuts
Ready to set up some keyboard shortcuts? Click the New icon> select Phrase> provide a name for your new phrase like 'My address'> OK:
First enter the address (1), and then select 'Always ask before pasting this phrase’ (2) since you will want to have some kind of mouse-based confirmation when you entered the keyboard shortcut sequence. The reason for this is that it may be in some application, like your Slack workspace at work, and accidentally typing your key sequence associated with the address.
Since this particular sequence has new lines (as an example, after 'My name'), when these keyboard sequences are sent, you will have no way to stop them and all text will be sent wherever you are working. As confirmed by the new lines (how to enter) messages in many communication tools, your message will be sent (except the last line) even before I can say 'whoopsie’ 🙂
Next, we also add it as a new option to our notification icon / taskbar by clicking 'Show in notification icon menu’ (3) and finally we make sure that we are hitting by keyboard, even though you may want to try other options in this field for various paste text scenarios (In other words, insert).
Almost done. Now we need to assign a keyboard sequence / shortcut and for that we click on 'Determine’ (5) for Abbreviations. Then we are presented with the following dialog box:
First, click on the 'Add button’ (1). First, type your preferred keyboard sequence (I regularly use a letter and prefix '//’ since it is a keyboard sequence that is not used many times (Unless you are a programmer who writes comments directly after // comment lines instead of using a space).
For this case we set ‘// m’. Now comes a bit tricky part due to a small deficiency in the AutoKey GUI. Do not click anywhere other than in the blank space just below the newly set abbreviation. As an example, click where the circle is (2) in the screenshot above. This will block the abbreviation sequence / keyboard instead of deleting it again. You will get used to it soon.
Next, we want to make sure that the 'Remove written abbreviation’ is marked (3) and that we select 'Activate immediately (does not need a trigger character) (4). Remember we mentioned that some things are a bit confusing? This is one of them. Can determine trigger characters above and beyond, as prefix, of the sequences / keyboard abbreviations, but this is often unnecessary and we can enable simpler use of AutoKey by selecting this option. Finally, click 'OK’ (5) to confirm everything.
All ready! Now just open your favorite text editor (Yes, inclusive we / vim Inside a terminal it will work!) and type your keyboard sequence '// m'. If everything went well, You should now see a small 'My Address' pop-up’ where the mouse cursor is at that moment, allowing you to click and render the text:
If you should see a result similar to the following:
Try changing the 'Paste using’ from your keyboard to the Phrase to 'Clipboard (Ctrl + V)’ instead:
And you should be ready.
Ending
AutoKey is a great utility that can save you many hours of repetitive typing work.
Despite this, has its own shortcomings and even problems, as discussed. AutoKey has been around for many years and, hoping current developers fix some of the shortcomings, will be available for many productive years. Enjoy!