Autokey is a desktop automation utility for Linux. You can use it as a text expander to create your own shortcuts for the functions you use the most in your favorite software. You’ll also have the choice to map longer pieces of text – or even whole templates – to short string abbreviations.
As you get more familiar with Autokey, you’ll find that you can do much more with it. You can automate desktop applications to perform the same tedious tasks without your input or even create your own mini-apps. Let’s see how you can use Autokey to automate your daily life with your computer.
Installation
In this tutorial we are installing and using the application in Ubuntu. The process should be similar in most distributions for which you can find a prepackaged file of the application.
You can seek Autokey in the Software Center if you prefer the visual way of bringing software on-board. You will find two versions: Autokey-GTK for Gnome, MATE, and other GTK-based desktop environments and Autokey-QT for KDE Plasma and anything else relying on the QT toolkit.
Similarly, if you’re a fan of the terminal, you can install it using apt, but you should choose the appropriate version using only one of the following:
sudo apt install autokey-gtk sudo apt install autokey-qt
Text Snippets
Locate AutoKey among your installed applications and run it.
AutoKey works with two different types of entries. You can use simple plaintext, which Autokey characterizes as phrases, to create shortcuts and text snippets that will be expanded to larger phrases (hence the name). You can also use it to automate complicated tasks by writing relatively simple Python scripts instead. Let’s start with the easy stuff, though, by creating a text expansion snippet.
The program comes with some sample content that will help you get familiar with how it works. Expand the “My Phrases” folder on the left list, then the Addresses subfolder inside it, and choose the Home Address entry.
Notice how there are four lines of text in the program’s main window and how under that, next to Abbreviations, there is the string adr
. If you open a text editor with Autokey active, type “adr,” press Enter, and it will get replaced by the contents in Autokey’s main window. That’s how you can set up your own text snippets. Let’s create one together.
Click on New on the program’s toolbar and choose Phrase from the pop-up menu that appears.
Enter a name for your snippet – we used MTE.
Choose your new entry from the list on the left, if it isn’t already selected, and erase the placeholder text in the central part of the window. Replace it with the text you want to appear when you type an abbreviation – we entered our site’s name, Make Tech Easier.
Click on the “Set button” next to Abbreviations, then click on Add on the left of the window that will pop up. Type the abbreviation that you want to be expanded to the text snippet you defined in the previous step.
Run your favorite text editor and type the abbreviation you defined. If everything went according to plan, the snippet will replace your abbreviation.
Instead of using abbreviations, you can also assign keyboard shortcuts to text snippets – just choose to set a Hotkey instead of an Abbreviation. Both options are at the same spot. You can also map hotkeys to folders that contain multiple snippets. If you press the hotkey afterward, a pop-up menu with the folder’s contents will appear. You can choose an entry from there to have its contents pasted in the program you are using.
Automation Using Autokey
The simple way to automate stuff is by replicating the keypresses that achieve the result you wish in your favorite application. For example, we want to have our text editor save the file we are working with using the name “MTE.txt.” By typing Ctrl + s in the main window, we tell Autokey to send the combination CTRL + S to the application. Then, we can follow by entering the file’s name in the next line.
With this approach, you can create sequences of keypresses to automate any application that can be controlled with the keyboard. You can use other special keys in your scripts, always in brackets: alt, enter, escape, tab, shift, and super for the Windows key.
Advanced Scripting
Theoretically, Autokey allows you to create some relatively advanced automation solutions without creating Python scripts from scratch. Practically, though, its latest version failed us in that regard. You can do it by choosing the option “Record keyboard/mouse” from the Tools menu, but whenever we tried that, the application crashed.
Autokey can be an excellent introduction to Python, though, since the examples it comes with, which you can find inside the folder Sample Scripts, are relatively easy to understand. You can use them as a base for your own scripts, creating even more complex automation solutions.
Are you already using a text expander or some other automation solution? If you are looking for a clipboard manager instead, try CopyQ.
Our latest tutorials delivered straight to your inbox