Crates.io | mouse-rs |
lib.rs | mouse-rs |
version | 0.4.2 |
source | src |
created_at | 2020-09-19 03:18:31.303976 |
updated_at | 2022-06-05 14:48:24.794573 |
description | Library to control your mouse via rust |
homepage | https://docs.rs/mouse-rs/*/mouse_rs/ |
repository | https://github.com/AltF02/mouse-rs |
max_upload_size | |
id | 290350 |
size | 34,796 |
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
Add mouse-rs to your cargo.toml
[dependencies]
mouse-rs = "0.4"
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");
}
For more information please visit the docs
If you're running into problems building on linux you need to install libxdo-dev.
sudo apt-get install -y libxdo-dev
sudo pacman -Sy xdotool
sudo dnf install libX11-devel libxdo-devel
sudo emerge xdotool