INNER CODE UNIT · Rust

mouse_click

keon/browser-control · src/actions.rs:24

pub async fn mouse_click(c: &mut Cdp, x: i64, y: i64, button: &str, clicks: u64) -> Result<()> {
    if !["left", "right", "middle", "back", "forward"].contains(&button) {
        bail!("bad button {button:?}; use left/right/middle/back/forward")
    }
    for t in ["mousePressed", "mouseReleased"] {
        c.call(
            "Input.dispatchMouseEvent",
            json!({"type":t,"x":x,"y":y,"button":button,"clickCount":clicks}),
            true,
        )
        .await?;
    }
    Ok(())
}

pub async fn wheel(c: &mut Cdp, x: i64, y: i64, dx: i64, dy: i64) -> Result<()> {
    c.call(
        "Input.dispatchMouseEvent",

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…