InputBot allows you to bind specific keys or mouse buttons to closures that execute when the input is detected. You can use KeySequence to simulate typing strings and press()/release() methods for mouse buttons.
To start the event loop and begin listening for bound inputs, you must call inputbot::handle_input_events(false).
use inputbot::{KeySequence, KeybdKey::*, MouseButton::*};
use std::{thread::sleep, time::Duration};
fn main() {
// Bind the number 1 key to type a string
Numrow1Key.bind(|| KeySequence("Hello, world!").send());
// Bind CapsLock to an autoclicker loop
CapsLockKey.bind(move || {
while CapsLockKey.is_toggled() {
LeftButton.press();
LeftButton.release();
sleep(Duration::from_millis(30));
}
});
// Start listening for bound inputs
inputbot::handle_input_events(false);
}