pub struct SmartMouse { /* private fields */ }Expand description
Tracks the current mouse position and generates human-like movement paths.
Uses lock-free atomics for interior mutability — safe to use behind Arc
and &self references without any mutex. Use this alongside CDP
Input.dispatchMouseEvent calls so that every movement starts from
the real cursor location instead of teleporting.
Implementations§
Source§impl SmartMouse
impl SmartMouse
Sourcepub fn with_config(config: SmartMouseConfig) -> Self
pub fn with_config(config: SmartMouseConfig) -> Self
Create a SmartMouse with custom configuration.
Sourcepub fn set_position(&self, point: Point)
pub fn set_position(&self, point: Point)
Set the mouse position directly (e.g., after a teleport or click).
Sourcepub fn config(&self) -> &SmartMouseConfig
pub fn config(&self) -> &SmartMouseConfig
Get the movement configuration.
Sourcepub fn path_to(&self, target: Point) -> Vec<MovementStep>
pub fn path_to(&self, target: Point) -> Vec<MovementStep>
Generate a movement path from the current position to target.
This updates the tracked position to target and returns a series of
MovementSteps for dispatching intermediate MouseMoved events.
Sourcepub fn pre_click_dwell(&self) -> Option<Duration>
pub fn pre_click_dwell(&self) -> Option<Duration>
Sample a randomized pre-click dwell duration from the configured
range, or None if the dwell is disabled.
The dwell is the pause between the final mouseMoved of an
approach and the mousePressed of the click. Real users always
take at least a few tens of milliseconds to commit; bot drivers
commonly press in the same task tick. Inserting this gap is one
of the cheaper detection-shape wins available.