veilus_human_input/lib.rs
1//! Human-like input for browser automation: mouse paths, wheel scrolling and
2//! typing rhythm.
3//!
4//! Every function is pure: it takes the parameters and a random number
5//! generator and returns points, deltas or durations. Sending them (CDP,
6//! WebDriver, OS events) is the caller's job, so the crate has no I/O and no
7//! async runtime, and a seeded RNG makes every result reproducible.
8//!
9//! ```
10//! use rand::{rngs::StdRng, SeedableRng};
11//! use veilus_human_input::{keyboard, mouse};
12//!
13//! let mut rng = StdRng::seed_from_u64(7);
14//! let params = mouse::MouseParams::default();
15//! let steps = mouse::path((40.0, 40.0), (600.0, 320.0), 80.0, ¶ms, &mut rng);
16//! assert_eq!(steps.last().map(|s| (s.x, s.y)), Some((600.0, 320.0)));
17//!
18//! let keys = keyboard::timings("hello", &keyboard::TypingParams::default(), &mut rng);
19//! assert_eq!(keys.len(), 5);
20//! ```
21//!
22//! The `Default` parameter sets are reasonable starting points, not a
23//! measurement of any particular person. Tune them for your own use.
24
25pub mod keyboard;
26pub mod mouse;
27pub mod wheel;
28
29mod sample;
30
31// Compile and run the README examples as doctests.
32#[doc = include_str!("../README.md")]
33#[cfg(doctest)]
34pub struct ReadmeDoctests;