mouce
Mouce is a library written in Rust that aims to help simulating and listening mouse actions across different platforms.
Supported platforms
- Windows ✅
- Tested on Windows 10
- Uses User32 system library
- MacOS ✅
- Tested on a MacBook Pro (Retina, 13-inch, Mid 2014) with Big Sur installed on it
- Uses CoreGraphics and CoreFoundation frameworks
- Unix-like systems
- X11 ✅
- Tested on i3wm Arch Linux
- Uses X11 and XTest libraries
- Others (partially supported) ❌
- For other systems, you can disable the x11 feature and the library will use uinput
- Use
--no-default-features
argument with cargo - Or disable default features in
Cargo.toml
[] = { = "x.y.z", = false }
- Use
- While using uinput there are some limitations for the library
get_position
function is not implemented as uinput does not provide such a feature- The rest of the actions work and tested on KDE Wayland and sway
- For other systems, you can disable the x11 feature and the library will use uinput
- X11 ✅
Library interface
/// Move the mouse to the given `x`, `y` coordinates in logical pixel space
;
/// Move the mouse relative to the current position in logical pixel space
;
/// Get the current position of the mouse in logical pixel space
;
/// Press down the given mouse button
;
/// Release the given mouse button
;
/// Click the given mouse button
;
/// Scroll the mouse wheel towards to the given direction
;
/// Attach a callback function to mouse events
;
/// Remove the callback function with the given `CallbackId`
;
/// Remove all callback functions
;
Example
This example program moves the mouse from left to right;
use thread;
use Duration;
use ;
To see more examples, you can look at the documentation by running;
cargo doc --open
CLI binary
mouce comes with an example CLI program that uses mouce library functions. You can install the binary with;
cargo install mouce --features="cli"
and see mouce --help
for further details.