SergioRibera / mouse_position

Rust crate to get mouse position on Linux, MacOS, and Windows.

Home Page:https://crates.io/crates/mouse_position

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Mouse Position

Note

Support for all platforms

  • Windows (winapi)
  • MacOS (core-graphics)
  • Linux (libinput)

A simple crate to get the mouse position in a cross platform way.

Example Usage:

use mouse_position::{Mouse, MouseExt};

fn main() {
    let mut mouse = Mouse::default();

    loop {
        let (x, y) = match mouse.get_pos() {
            Ok((x, y)) => (x, y),
            Err(e) => {
                println!("{e:?}");
                continue;
            }
        };

        println!("x: {x}, y: {y}");

        std::thread::sleep(std::time::Duration::from_millis(100));
    }
}

About

Rust crate to get mouse position on Linux, MacOS, and Windows.

https://crates.io/crates/mouse_position

License:MIT License


Languages

Language:Rust 86.1%Language:Nix 13.9%