Expand description
Noct lets you simulate mouse and keyboard input-events as if they were made by the actual hardware. The goal is to make it available on different operating systems like Linux, macOS and Windows – possibly many more but Redox and *BSD are planned. Please see the Repo for the current status.
I consider this library in an early alpha status, the API will change in in the future. The keyboard handling is far from being very usable. I plan to build a simple DSL that will resemble something like:
"hello {+SHIFT}world{-SHIFT} and break line{ENTER}"
The current status is that you can just print
unicode
characters like emoji without the {+SHIFT}
DSL
or any other “special” key on the Linux, macOS and Windows operating system.
Possible use cases could be for testing user interfaces on different plattforms, building remote control applications or just automating tasks for user interfaces unaccessible by a public API or scripting laguage.
For the keyboard there are currently two modes you can use. The first mode is represented by the key_sequence function its purpose is to simply write unicode characters. This is independent of the keyboardlayout. Please note that you’re not be able to use modifier keys like Control to influence the outcome. If you want to use modifier keys to e.g. copy/paste use the Layout variant. Please note that this is indeed layout dependent.
Examples
use noct::*;
let mut noct = Noct::new();
//paste
noct.key_down(Key::Control);
noct.key_click(Key::Layout('v'));
noct.key_up(Key::Control);
use noct::*;
let mut noct = Noct::new();
noct.mouse_move_to(500, 200);
noct.mouse_down(MouseButton::Left);
noct.mouse_move_relative(100, 100);
noct.mouse_up(MouseButton::Left);
noct.key_sequence("hello world");