Scripting - autokey/autokey GitHub Wiki
Contents
- Introduction
- Example scripts
- Contributing scripts
- Porting your scripts from Python 2 to Python 3
- Renaming scripts
Introduction
AutoKey scripts accept most Python code. AutoKey also offers some custom API functions that can be used in scripts. For specific details on the custom functions available to AutoKey scripts, see the API reference.
Example scripts
You can find several pages of example scripts and user-contributed scripts on the Example Scripts page as a demonstration of some of the basic and advanced capabilities of AutoKey's scripting service.
Contributing scripts
Feel free to use the scripts for your own purposes. However, if you significantly modify them or come up with something new as a result of using them, please post them in one of our community platforms so one of the wiki moderators can add them here for all to benefit.
All submitted scripts are publicly licensed as GNU GPL v3
Porting your scripts from Python 2 to Python 3
- Changes were made to source code to keep the scripting API stable. The
system.exec_command()
returns a string. But if you use functions from the standard library, you will have to fix that, as your script runs on a Python 3 interpreter. For example, expectsubprocess.check_output()
to return a bytes object. - The 2to3 Python program can be used to automatically translate your source code from Python 2 to Python 3.
- Some guides on porting code to Python 3:
Renaming scripts
Rename a script in AutoKey
- Open AutoKey's main window.
- Click the greater-than symbol next to your Sample Scripts directory.
- Browse to the script you'd like to rename.
- Right-click its name.
- Choose Rename from the context menu.
- Type in the new name.
- Make sure that the Update name on file system box has a check-mark in it (it's checked by default).
- Click the OK button.
Rename a script in your file manager
- Open your file manager.
- Open the
~/.config/autokey/data/Sample Scripts
directory. - Find the
.json
and.py
files for your script. - Edit the name of its
.py
file. - Edit the name of its
.json
file. - Open its
.json
file in a text editor. - Edit its name in the description field.
- Save the change.
- Shut down AutoKey.
- Restart AutoKey.