It's for repetitive tasks that are too small to be bothered writing a macro script into something like AutoHotKey, but annoying and repetitive enough that you want some automation.
It allows you to record some keypresses, and then replay those keypresses, using keyboard shortcuts. It's like the clipboard, but for keypresses instead of text. Recordings do not persist across restarts/logins, and are overwritten when you record a new macro. (Does not actually interact with the clipboard at all)
- Add keyboard shortcuts to trigger the
record.py
andreplay.py
scripts. They work globally on the OS. I use ctrl+super+e for record and super+e for replay. - Install
keyboard
python library. - Change the
authkey
in all files (just to be safe)
Do this once, ever.
Start server.py
as super user. e.g. sudo python server.py
Do this every time you start your system. Add to startup applications to be fancy. I used this guide to add it to systemd.
- Press the record shortcut (ctrl+super+e).
- Do the task like normal.
- Press
esc
to stop recording. - Press the replay shortcut (super+e) as many times as you need.
- You have to release the modifier key of the triggering key chord before the macro will execute. Make sure to not press any modifier keys while it is running, else the key presses of the macro will be triggered with that modifier key. E.g. if your macro includes the 'q' key, and you accidentally hold ctrl while it plays back, it will close your window.
- It defaults to replaying as fast as it can. If you need a timed playback, modify line 24 of the server; change the
0
to something like2.0
(for double-speed playback) and restart the server. (see: https://github.com/boppreh/keyboard?tab=readme-ov-file#keyboard.play)