Welcome to AutoKey, the free desktop automation utility for Linux. Do you often use templates, repeat keystrokes or other repetitive tasks? If so, AutoKey is a great toolkit you do not want to miss out on!
What is AutoKey?
Let’s say you often type your email address, or your postal address. It can be a bit frustrating to have to type it out every time. Let AutoKey do it for you! All you have to do is to associate a keyboard shortcut – a set of keystroke events – with a particular blurb of text.
Another easy to setup function is keyboard automation. AutoKey supports various key events like a left or right cursor press (the left and right arrow on your keyboard). To include this in your text blurb, all you have to is to use a small command which represents what to do:
In this sequence, we insert (as text) the
code HTML tag and then press the
left key seven times. This is very handy when you’re developing HTML in a text editor and would like to quickly insert a code tag and be taken back to the place where the code started (first
code tag), and before the code block ends (second tag,
/code). In other words, the seven
left presses bring us nicely to just inside the
We can also automate form-filling by inserting tabs etc.
Regrettably, there are some minor issues with the AutoKey program that you should be aware of. On Ubuntu 20.04.1 and using the dpkg based installation, AutoKey may crash when trying to record a macro by using the keyboard/mouse (Tools > Record keyboard/mouse). This functionality is generally speaking not needed for the purposes described in this guide.
Another issue is that AutoKey is somewhat complex to get setup the first time unless you have a guide like this one to follow. Especially the possibility to assign keyboard shortcuts (abbreviations as well as hotkeys) to folders as well as individual ‘phrases’ (think about this term as actual keyboard assignments to text blurbs).
Finally, AutoKey, at least on Ubuntu 20.04.1 sometimes fails to respond to a keyboard sequence you’ve programmed it to respond to. An easy workaround for this issue is to click the AutoKey icon on the dock to bring it to the foreground and click it. You will find if you swap back to your workspace, the key sequences will work again.
Even with these shortcomings, which may be resolved in due time, AutoKey is a must-have tool. Not having to type one’s address over and over, pressing only two to three keys to paste in your email (any keystrokes are removed automatically), and the ability to have full document templates at the price of a few keys and a mouse click (to confirm the keyboard sequence), are invaluable.
This guide assume 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, Mint and other Debian based operating system users, see Debian and Derivatives.
You can also try:
sudo apt install autokey-gtk
You can also install AutoKey using Python pip, see pip based installation
If you already have an existing AutoKey installation, it is important to remove it first. And, before doing so, you may want to backup your configuration in
Setting up AutoKey
Once you have AutoKey setup, open it up and you should see the main interface:
As you can see, I already have some AutoKey setup. AutoKey has many features, including a full scripting interface:
The first thing you will want to do is to setup the preferences. Click Edit > Preferences. You will be presented with the following window:
We tick the first 3 options to (1) ensure that AutoKey starts on startup, (2) Auto-save changes and (3) to show a notification icon in the Taskbar, which in Ubuntu presents itself as follows:
You can use this notification icon to quickly use some items without having to use keyboard shortcuts, as well as opening the application directly.
Using AutoKey: Keyboard Shortcuts
Ready to setup some keyboard shortcuts? Click the New icon > select Phrase > provide a name for your new phrase like ‘My Address’ > OK:
Next, we can enter our address:
First enter the address (1), and next select ‘Always prompt before pasting this phrase’ (2) as you will want to have some form of mouse-based confirmation when you typed your keyboard shortcut sequence. The reason for this is that you may be in some application, like your Slack workspace at work, and accidentally type your key sequence associated with the address.
As this particular sequence has newlines in it (for example after ‘My Name’), when these keyboard sequences are sent you will have no way to stop them and all text will be sent to whatever place you are working in. As the newlines confirm (like enter) messages in many communication tools, your message will be sent (except the last line) even before you can say ‘whoopsie’ :)
Next we also add it as a new option to our notification/taskbar icon by clicking ‘Show in notification icon menu’ (3) and finally we make sure that we are pasting in by Keyboard, though you may like to test other options in this field for various text paste (i.e. insert) scenario’s.
Almost done. Now we need to assign a keyboard sequence/shortcut and for that we click on ‘Set’ (5) for Abbreviations. We are then presented with the following dialog:
First, click the ‘Add’ button (1). First, type in your preferred keyboard sequence (I usually use a letter and prefix it by ‘//’ as that is a not-often used keyboard sequence (unless you’re a programmer who types comments directly after // remark lines instead of using a space).
In this case we set ‘//m’. Now comes a slightly tricky part due to a minor shortcoming in the AutoKey GUI. Do not click anywhere else then in the whitespace just under the newly defined abbreviation. For example, click where the (2) circle is in the screenshot above. This will lock in the abbreviation / keyboard sequence instead of removing it again. You will soon get used to it.
Next we want to ensure the ‘Remove typed abbreviation’ is ticked (3) and that we select ‘Trigger immediately (don’t require a trigger character) (4). Remember how we mentioned some things are slightly confusing? This is one of them. You can set trigger characters above and beyond, as a prefix, to keyboard sequences / abbreviations, but this is often unnecessary and we can enable more simple usage of AutoKey by selecting this option. Finally, click ‘OK’ (5) to confirm everything.
All done! Now simply open your favorite text editor (yes even vi/vim inside a terminal will work!) and type your keyboard sequence ‘//m’. If all went well, you should now see a little ‘My Address’ popup where your mouse cursor is located in that moment, allowing you to click it and render the text:
If you should see output similar to the following:
Try and change your keyboard ‘Paste using’ method for the Phrase to ‘Clipboard (Ctrl+V)’ instead:
And you should be all set.
AutoKey is a great utility which may save you many hours of repetitive typing work.
It does however come with it’s own shortcomings and even issues as discussed. AutoKey has been around for many years and – with the hope that the current developers will fix some of the shortcomings – will be around for many productive years to come! Enjoy!
- › How Much Does It Cost to Operate an Electric Lawn Mower?
- › Don’t Put Your TV Over Your Fireplace
- › Does Hibernating My PC Save More Energy Than Sleep?
- › What Are the Best Nintendo Switch Games in 2022?
- › Picsart Gold Review: A True Treasure for Quick Photo and Video Editing
- › What’s New in Windows 11’s 22H2 Update: Top 10 New Features