thirtyfour-mouse

Crates.iothirtyfour-mouse
lib.rsthirtyfour-mouse
version0.2.1
created_at2024-12-19 03:47:07.988809+00
updated_at2025-09-19 23:02:11.088877+00
descriptionManipulate mouse movements with ThirtyFour
homepage
repositoryhttps://github.com/0xlunar/thirtyfour-mouse
max_upload_size
id1488761
size83,956
(0xlunar)

documentation

README

thirtyfour-mouse

Adjustable mouse movement controls for Thirtyfour

Example

use std::time::Duration;

#[tokio::main]
async fn main() {
    let caps = DesiredCapabilities::chrome();
    let driver = WebDriver::new("http://localhost:9515", caps).await.unwrap();
    driver.goto("https://autodraw.com/").await.unwrap();
    sleep_until(Instant::now() + Duration::from_millis(500)).await;

    // Start Drawing Button
    match driver.find(By::Css("div[class=\"button green\"]")).await {
        Ok(btn) => {
            btn.click().await.unwrap();
        }
        Err(_) => ()
    };
    sleep_until(Instant::now() + Duration::from_millis(500)).await;

    // Pencil Tool
    let draw_icon = driver.find(By::Css("div[class=\"tool pencil\"]")).await.unwrap();
    draw_icon.click().await.unwrap();

    // Start Somewhere on the canvas.
    driver.action_chain_with_delay(None, Some(0)).move_to(900, 700).perform().await.unwrap();

    // Draw on mouse path canvas
    let mouse_action = MouseAction::new(
        MouseInterpolation::Spline,
        MouseButtonAction::LeftHold,
        MouseButtonAction::LeftRelease,
        Some(Duration::from_secs(2)), // Exact duration not guaranteed, but should be close
        Some(1)
    );
    driver.mouse_action(mouse_action, &draw_icon).await.unwrap();

    sleep_until(Instant::now() + Duration::from_millis(10_000)).await;

    driver.quit().await.unwrap();
}
Commit count: 11

cargo fmt