computers/default/scrapybara.py [81:131]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    def screenshot(self) -> str:
        return self.instance.screenshot().base_64_image

    def click(self, x: int, y: int, button: str = "left") -> None:
        button = "middle" if button == "wheel" else button
        self.instance.computer(
            action="click_mouse",
            click_type="click",
            button=button,
            coordinates=[x, y],
            num_clicks=1,
        )

    def double_click(self, x: int, y: int) -> None:
        self.instance.computer(
            action="click_mouse",
            click_type="click",
            button="left",
            coordinates=[x, y],
            num_clicks=2,
        )

    def scroll(self, x: int, y: int, scroll_x: int, scroll_y: int) -> None:
        self.instance.computer(
            action="scroll",
            coordinates=[x, y],
            delta_x=scroll_x // 20,
            delta_y=scroll_y // 20,
        )

    def type(self, text: str) -> None:
        self.instance.computer(action="type_text", text=text)

    def wait(self, ms: int = 1000) -> None:
        time.sleep(ms / 1000)
        # Scrapybara also has `self.instance.computer(action="wait", duration=ms / 1000)`

    def move(self, x: int, y: int) -> None:
        self.instance.computer(action="move_mouse", coordinates=[x, y])

    def keypress(self, keys: list[str]) -> None:
        mapped_keys = [
            CUA_KEY_TO_SCRAPYBARA_KEY.get(key.lower(), key.lower()) for key in keys
        ]
        self.instance.computer(action="press_key", keys=mapped_keys)

    def drag(self, path: list[dict[str, int]]) -> None:
        if not path:
            return
        path = [[point["x"], point["y"]] for point in path]
        self.instance.computer(action="drag_mouse", path=path)
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



computers/default/scrapybara.py [167:217]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    def screenshot(self) -> str:
        return self.instance.screenshot().base_64_image

    def click(self, x: int, y: int, button: str = "left") -> None:
        button = "middle" if button == "wheel" else button
        self.instance.computer(
            action="click_mouse",
            click_type="click",
            button=button,
            coordinates=[x, y],
            num_clicks=1,
        )

    def double_click(self, x: int, y: int) -> None:
        self.instance.computer(
            action="click_mouse",
            click_type="click",
            button="left",
            coordinates=[x, y],
            num_clicks=2,
        )

    def scroll(self, x: int, y: int, scroll_x: int, scroll_y: int) -> None:
        self.instance.computer(
            action="scroll",
            coordinates=[x, y],
            delta_x=scroll_x // 20,
            delta_y=scroll_y // 20,
        )

    def type(self, text: str) -> None:
        self.instance.computer(action="type_text", text=text)

    def wait(self, ms: int = 1000) -> None:
        time.sleep(ms / 1000)
        # Scrapybara also has `self.instance.computer(action="wait", duration=ms / 1000)`

    def move(self, x: int, y: int) -> None:
        self.instance.computer(action="move_mouse", coordinates=[x, y])

    def keypress(self, keys: list[str]) -> None:
        mapped_keys = [
            CUA_KEY_TO_SCRAPYBARA_KEY.get(key.lower(), key.lower()) for key in keys
        ]
        self.instance.computer(action="press_key", keys=mapped_keys)

    def drag(self, path: list[dict[str, int]]) -> None:
        if not path:
            return
        path = [[point["x"], point["y"]] for point in path]
        self.instance.computer(action="drag_mouse", path=path)
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



