Skip to content

Mouse

Mouse performs screen-coordinate mouse actions.

Mouse

Control the mouse at absolute screen coordinates.

Usage::

Mouse.click(100, 200)
Mouse.right_click(500, 300)
Mouse.double_click(400, 150)
Mouse.move(x=640, y=480)
Mouse.scroll(x=400, y=300, wheel_dist=3)
Source code in src\dolphin_desktop\_mouse.py
class Mouse:
    """Control the mouse at absolute screen coordinates.

    Usage::

        Mouse.click(100, 200)
        Mouse.right_click(500, 300)
        Mouse.double_click(400, 150)
        Mouse.move(x=640, y=480)
        Mouse.scroll(x=400, y=300, wheel_dist=3)
    """

    @staticmethod
    def click(x: int, y: int, button: str = "left") -> None:
        _mouse.click(button=button, coords=(x, y))

    @staticmethod
    def double_click(x: int, y: int, button: str = "left") -> None:
        _mouse.double_click(button=button, coords=(x, y))

    @staticmethod
    def right_click(x: int, y: int) -> None:
        _mouse.right_click(coords=(x, y))

    @staticmethod
    def move(x: int, y: int) -> None:
        _mouse.move(coords=(x, y))

    @staticmethod
    def scroll(x: int, y: int, wheel_dist: int) -> None:
        """Scroll at (x, y). Positive wheel_dist scrolls up."""
        _mouse.scroll(coords=(x, y), wheel_dist=wheel_dist)

    @staticmethod
    def press(x: int, y: int, button: str = "left") -> None:
        _mouse.press(button=button, coords=(x, y))

    @staticmethod
    def release(x: int, y: int, button: str = "left") -> None:
        _mouse.release(button=button, coords=(x, y))

scroll staticmethod

scroll(x: int, y: int, wheel_dist: int) -> None

Scroll at (x, y). Positive wheel_dist scrolls up.

Source code in src\dolphin_desktop\_mouse.py
@staticmethod
def scroll(x: int, y: int, wheel_dist: int) -> None:
    """Scroll at (x, y). Positive wheel_dist scrolls up."""
    _mouse.scroll(coords=(x, y), wheel_dist=wheel_dist)

Usage

from dolphin_desktop import Mouse

Mouse.move(100, 200)
Mouse.click(100, 200)
Mouse.click(100, 200, button="right")
Mouse.right_click(100, 200)
Mouse.double_click(100, 200)

Mouse.press(100, 200, button="left")
Mouse.move(300, 200)
Mouse.release(300, 200, button="left")

Mouse.scroll(100, 200, wheel_dist=3)   # positive scrolls up
Mouse.scroll(100, 200, wheel_dist=-3)  # negative scrolls down

Prefer Locator.click(), Locator.hover(), and Locator.drag_to() when you can identify an element. Use Mouse for low-level coordinate workflows.