mokr.input.mouse
Classes
Class to emulate mouse movement. |
Module Contents
- class mokr.input.mouse.Mouse(client: mokr.connection.DevtoolsConnection, keyboard: mokr.input.keyboard.Keyboard)
Class to emulate mouse movement.
The
Mouse’s remote position is measured in pixels, with origin at the top-left corner of the viewport.- Parameters:
client (DevtoolsConnection) – Remote
DevtoolsConnectioninstance.keyboard (Keyboard) – Active
mokr.input.Keyboardfrom the parentmokr.input.Keyboard. Passes active modifiers such as CTRL.
- async move(x: float, y: float, steps: int = 1) None
Move the mouse to target coordinates (
x,y), sending intermittent events along the trail for each step insteps.- Parameters:
x (float) – Target X coordinate.
y (float) – Target Y coordinate.
steps (int, optional) – Number of times to stop along the path. Defaults to 1 (final destination only).
- async down(button: Literal['left', 'right', 'middle'] = 'left', click_count: int = 1) None
Send a “mousePressed” event with given mouse
button, repeat forclick_countnumber of times.- Parameters:
button (Literal["left", "right", "middle"], optional) – Mouse button to send with. Defaults to “left”.
click_count (int, optional) – Number of click events to send. Defaults to 1.
- async up(button: Literal['left', 'right', 'middle'] = 'left', click_count: int = 1) None
Send a “mouseReleased” event with given mouse
button, repeat forclick_countnumber of times.- Parameters:
button (Literal["left", "right", "middle"], optional) – Mouse button to send with. Defaults to “left”.
click_count (int, optional) – Number of click events to send. Defaults to 1.
- async click(x: float, y: float, button: Literal['left', 'right', 'middle'] = 'left', click_count: int = 1, delay: int | float | None = 1000) None
Move the pointer to the target coordinates and click.
Shortcut to running
Mouse.movethenMouse.downthenMouse.up.- Parameters:
x (float) – X coordinate to move to.
y (float) – Y coordinate to move to.
button (Literal["left", "right", "middle"], optional) – Mouse button to click with. Defaults to “left”.
click_count (int, optional) – Number of clicks to run. Defaults to 1.
delay (int | float | None, optional) – Time in milliseconds to wait before each click. Defaults to 1000.