simulate
allows you to simulate input events (such as keyboard keystrokes or mouse mouvement) through code.
Progress
At the movement, only Windows is supported.
Examples
simulate
can be used to simulate keyboard keystrokes:
use simulate;
use Key;
// Release a key
press.unwrap;
// Send a key (press + release)
send.unwrap;
// Release a key
release.unwrap;
// Send a single character
send.unwrap;
// Type a string
type_str.unwrap;
It can also simulate mouse events:
use ;
// Mouse buttons are treated as keys
send.unwrap;
// Move the mouse 100 pixels left, 50 pixels down
move_mouse_relative.unwrap;
// Move the mouse at the center of the screen.
move_mouse_absolute.unwrap;
// Rotate the mouse wheel forward
scroll.unwrap;
// Rotate the mouse wheel to the left
scroll_horizontal.unwrap;
Events can be buffered using the EventBuffer
structure:
use ;
// This is really just a Vec<simulate::Event>
let mut buffer = new;
buffer.press;
buffer.send;
buffer.send;
buffer.release;
buffer.move_mouse_relative;
buffer.send;
buffer.simulate.unwrap;
Events can be created directly with the Event
structure:
use ;
let my_event = MoveMouseAbsolute ;
// Send a single event
send_event.unwrap;