#mouse #winapi #input

mouse-rs

Library to control your mouse via rust

14 releases

0.4.2 Jun 5, 2022
0.4.1 Sep 24, 2020
0.3.2 Sep 22, 2020
0.2.2 Sep 20, 2020
0.1.4 Sep 19, 2020

#499 in Hardware support

Download history 85/week @ 2023-11-20 88/week @ 2023-11-27 52/week @ 2023-12-04 71/week @ 2023-12-11 85/week @ 2023-12-18 141/week @ 2023-12-25 51/week @ 2024-01-01 87/week @ 2024-01-08 72/week @ 2024-01-15 99/week @ 2024-01-22 58/week @ 2024-01-29 72/week @ 2024-02-05 73/week @ 2024-02-12 107/week @ 2024-02-19 117/week @ 2024-02-26 127/week @ 2024-03-04

433 downloads per month
Used in 6 crates

MIT/Apache

21KB
379 lines

Rust Docs Crates.io

Mouse-rs

Mouse-rs is a rust library for controlling your mouse from a rust program, without having to go into your kernel yourself.

This project was loosely based on the python mouse library. Currently it supports macos, windows and linux (X11)! If you need any other OS added please open an issue

Installation

Add mouse-rs to your cargo.toml

[dependencies]
mouse-rs = "0.4"

Example

This is a simple example that moves your mouse to a position on screen and presses the left button.

use mouse_rs::{types::keys::Keys, Mouse};

fn move_and_press() {
    let mouse = Mouse::new();
    mouse.move_to(500, 500).expect("Unable to move mouse");
    mouse.press(&Keys::RIGHT).expect("Unable to press button");
    mouse.release(&Keys::RIGHT).expect("Unable to release button");
}

Usage

For more information please visit the docs

Linux disclaimer

If you're running into problems building on linux you need to install libxdo-dev.

Debian-based

sudo apt-get install -y libxdo-dev

Arch

sudo pacman -Sy xdotool

Fedora

sudo dnf install libX11-devel libxdo-devel

Gentoo

sudo emerge xdotool

Dependencies

~0–790KB
~13K SLoC