Simulating keyboard on Linux, Windows and Mac OS in rust
On the next example, the library simulates key A, Z pressed.
The keyboard layout on the computer is important!
If you use a keyboard layout the US, you have corresponding keys, but if you use, for example, the french layout, you have another result.
extern crate keybd_event;
use sleep;
use Duration;
use ;
use KeyBondingInstance;
Linux
On Linux this library use uinput, but generally the uinput is only for the root user.
The easy solution is executing on root user or change permission by chmod
, but it is not good.
You can follow the next example, for more security.
|
|
Another subtlety on Linux, it is important after creating KeyBondingInstance, to waiting 2 seconds before running first keyboard actions
Darwin (MAC OS)
This library depends on the frameworks Apple, I did not find a solution for cross-compilation.