| Crates.io | windmouse-rs |
| lib.rs | windmouse-rs |
| version | 0.1.1 |
| created_at | 2024-09-04 15:14:24.25946+00 |
| updated_at | 2024-09-04 15:23:07.918+00 |
| description | A rust implementation of windmouse |
| homepage | |
| repository | https://github.com/MostlyFinished/windmouse-rs |
| max_upload_size | |
| id | 1363417 |
| size | 14,781 |
WindMouse is a Rust implementation of the WindMouse algorithm, designed to generate realistic mouse movement paths. This library simulates mouse movements with consideration for gravity, wind, and randomness to create more human-like cursor trajectories.
See https://ben.land/post/2021/04/25/windmouse-human-mouse-movement/ for more details on the original algorithm
Add this to your Cargo.toml:
[dependencies]
windmouse = "0.1.0"
use windmouse::{WindMouse, Coordinate};
fn main() {
let wind_mouse = WindMouse::new_default();
let start = Coordinate::new(0.0, 0.0);
let end = Coordinate::new(100.0, 100.0);
let points = wind_mouse.generate_points(start, end);
for point in points {
println!("x: {}, y: {}, wait: {}ms", point[0], point[1], point[2]);
}
}
WindMouseThe main struct that holds the parameters for the mouse movement algorithm.
new(mouse_speed: f32, gravity: f32, wind: f32, min_wait: f32, max_wait: f32, max_step: f32, target_area: f32) -> Result<Self, WindMouseError>
Creates a new WindMouse instance with the specified parameters.
new_default() -> Self
Creates a new WindMouse instance with default values for all parameters.
generate_points(&self, start: Coordinate, end: Coordinate) -> Vec<[i32; 3]>
Generates a series of points representing the mouse movement path from the start coordinate to the end coordinate.
CoordinateA struct representing a 2D coordinate with floating-point precision.
new(x: f32, y: f32) -> Self
Creates a new Coordinate instance.
as_i32(&self) -> [i32; 2]
Converts the floating-point coordinate to integer values.
You can customize the behavior of the WindMouse algorithm by adjusting the following parameters:
gravity: Influences how strongly the mouse is pulled towards the target.wind: Determines the amount of randomness in the mouse's path.min_wait: The minimum time (in milliseconds) to wait between mouse movements.max_wait: The maximum time (in milliseconds) to wait between mouse movements.max_step: The maximum distance the mouse can move in a single step.target_area: The distance from the end point at which the algorithm starts to slow down and become more precise.mouse_speed: A general speed factor for the mouse movement.Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.