Simple library to listen and send events to keyboard and mouse.
You can also check out Enigo which is another crate which helped me write this one.
This crate is so far a pet project for me to understand the rust ecosystem.
Simple Usage
Listening to global events
use ;
Sending some events
use ;
use ;
Events enum
In order to manage different OS, the current EventType choices is a mix&match to account for all possible events. There is a safe mechanism to detect events no matter what, which are the Unknown() variant of the enum which will contain some OS specific value. Also not that not all keys are mapped to an OS code, so simulate might fail if you try to send an unmapped key. Sending Unknown() variants will always work (the OS might still reject it).
/// In order to manage different OS, the current EventType choices is a mix&match
/// to account for all possible events.
OS Specificities
For now the code only works for Linux (X11), MacOS and Windows. On MacOS, the listen
loop needs to be the primary app (no fork before) and need to have accessibility
settings enabled. The listen_and_simulate
test does have both a listen and a simulate part.
We use tokio to manage the listen process (Terminal was added in accessibility settings).