kuruhuru / InputBot

A Rust library for creating global hotkeys, and emulating inputs.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

InputBot docs link crates.io version

Cross-platform (Windows & Linux) library for simulating keyboard/mouse input events and registering global input device event handlers.

Allows writing automation programs that collapse long action-sequences into single key-presses.

Usage sample

use inputbot::{KeybdKey::*, MouseButton::*, *};
use std::{thread::sleep, time::Duration};

fn main() {
    // Autorun for videogames.
    NumLockKey.bind(|| {
        while NumLockKey.is_toggled() {
            LShiftKey.press();
            WKey.press();
            sleep(Duration::from_millis(50));
            WKey.release();
            LShiftKey.release();
        }
    });

    // Rapidfire for videogames.
    RightButton.bind(|| {
        while RightButton.is_pressed() {
            LeftButton.press();
            sleep(Duration::from_millis(50));
            LeftButton.release();
        }
    });

    // Send a key sequence.
    RKey.bind(|| KeySequence("Sample text").send());

    // Move mouse.
    QKey.bind(|| MouseCursor::move_rel(10, 10));

    // Call this to start listening for bound inputs.
    handle_input_events();
}

Build Dependencies

Debian or Ubuntu based distros

  • libx11-dev
  • libxtst-dev
  • libudev-dev

Runtime Dependencies

Debian or Ubuntu based distros

  • libinput-dev

Note: libinput requires InputBot to be run with sudo on Linux - sudo ./target/debug/<program name>.

About

A Rust library for creating global hotkeys, and emulating inputs.

License:MIT License


Languages

Language:Rust 100.0%