keyflow 0.1.1

Cross-platform input simulation library for keyboard, mouse and hotkeys.
Documentation
use keyflow::prelude::*;
use std::thread;
use std::time::Duration;

mod helper;

fn main() -> Result<()> {
    Keyflow::builder()
        .with_screen(Screen::default()) // Required only on Linux, if targets windows this just get ignored
        .initialize()?;

    // On linux need to wait until the virtual device is registered and focus a text editor in the meantime :)
    thread::sleep(Duration::from_secs(3));

    // Type text
    helper::type_text("Hello Keyflow");
    thread::sleep(Duration::from_millis(500));

    // Select all
    Keyflow::press_key(Key::ControlLeft);
    Keyflow::click_key(Key::A);
    Keyflow::release_key(Key::ControlLeft);
    thread::sleep(Duration::from_millis(500));

    Keyflow::click_key(Key::Enter);
    thread::sleep(Duration::from_millis(500));

    // Move mouse to x:500 y:300
    Keyflow::move_to(500, 300);
    thread::sleep(Duration::from_millis(500));

    // Click left mouse button
    Keyflow::click_button(Button::Left);
    thread::sleep(Duration::from_millis(500));

    // Move mouse relative x:+100 y:-50
    Keyflow::move_by(100, 50);
    thread::sleep(Duration::from_millis(500));

    // Scrolling
    Keyflow::scroll_vertical(-3); // negative values scroll down
    thread::sleep(Duration::from_millis(500));
    Keyflow::scroll_vertical(3); // positive values scroll up

    // Need to wait, so the main thread is still alive until the eventhandler finishes
    // In real applications this may not be the case.
    thread::sleep(Duration::from_secs(2));
    Ok(())
}