#input-event #input #keyboard-input #hotkey #mouse #keyboard #bot

inputbot

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

13 releases

0.6.0 Aug 17, 2023
0.5.1 Sep 5, 2021
0.5.0 Aug 30, 2020
0.4.0 Dec 23, 2017
0.1.2 Jun 19, 2017

#212 in Hardware support

Download history 121/week @ 2024-01-06 136/week @ 2024-01-13 88/week @ 2024-01-20 59/week @ 2024-01-27 68/week @ 2024-02-03 121/week @ 2024-02-10 169/week @ 2024-02-17 225/week @ 2024-02-24 165/week @ 2024-03-02 304/week @ 2024-03-09 234/week @ 2024-03-16 197/week @ 2024-03-23 278/week @ 2024-03-30 179/week @ 2024-04-06 186/week @ 2024-04-13 187/week @ 2024-04-20

855 downloads per month
Used in 5 crates

MIT license

59KB
1.5K SLoC

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

[dependencies]
inputbot = "0.6"
use inputbot::{KeySequence, KeybdKey::*, MouseButton::*};
use std::{thread::sleep, time::Duration};

fn main() {
    // Bind the number 1 key your keyboard to a function that types 
    // "Hello, world!" when pressed.
    Numrow1Key.bind(|| KeySequence("Hello, world!").send());

    // Bind your caps lock key to a function that starts an autoclicker.
    CapsLockKey.bind(move || {
        while CapsLockKey.is_toggled() {
            LeftButton.press();
            LeftButton.release();

            sleep(Duration::from_millis(30));
        }
    });

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

NOTE: The README and examples are based off the develop branch of InputBot. If a feature is not working, you are probably using the version from crates.io. If you want to use the latest build, add this to your Cargo.toml:

[dependencies]
inputbot = { git = "https://github.com/obv-mikhail/InputBot", branch = "develop" }

Check out examples for comprehensive examples on how to use each feature.

Build Dependencies

Debian or Ubuntu based distros

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

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

Examples

You can run the included examples by cloning the library and running cargo run --example <example name>. Similar to the note above, on Linux you have to run cargo build --examples && sudo ./target/debug/<example name>.

This is especially useful for testing the library when contributing.

Dependencies

~0.4–1.9MB
~35K SLoC