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

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.

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

fn moveandpress() { 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

bash sudo apt-get install -y libxdo-dev

Arch

bash sudo pacman -Sy xdotool

Fedora

bash sudo dnf install libX11-devel libxdo-devel

Gentoo

bash sudo emerge xdotool