Skip to content

Mouse

flaui.core.input.Mouse

Mouse class to simulate mouse input, wrapper over Mouse class in FlaUI.Core.Input namespace

are_buttons_swapped() staticmethod

Flag to indicate if the buttons are swapped (left-handed).

Source code in flaui/core/input.py
@staticmethod
def are_buttons_swapped() -> bool:
    """Flag to indicate if the buttons are swapped (left-handed)."""
    return CSMouse.AreButtonsSwapped

click(point=None, mouse_button=MouseButton.Left, post_wait=None) staticmethod

Clicks the specified mouse button at the current location.

Parameters:

Name Type Description Default
point Optional[Point]

The position to move to before clicking.

None
mouse_button MouseButton

The mouse button to click. Defaults to the left button, defaults to MouseButton.Left

Left
post_wait Optional[Union[bool, float, Callable[[], None]]]

Optional wait after operation. True=100ms, float=custom seconds, callable=custom function

None
Source code in flaui/core/input.py
@staticmethod
def click(
    point: Optional[Point] = None,
    mouse_button: MouseButton = MouseButton.Left,
    post_wait: Optional[Union[bool, float, Callable[[], None]]] = None,
) -> None:
    """Clicks the specified mouse button at the current location.

    :param point:The position to move to before clicking.
    :param mouse_button: The mouse button to click. Defaults to the left button, defaults to MouseButton.Left
    :param post_wait: Optional wait after operation. True=100ms, float=custom seconds, callable=custom function
    """
    CSMouse.Click(mouse_button.value) if point is None else CSMouse.Click(point.raw_value, mouse_button.value)
    Mouse._apply_post_wait(post_wait)

double_click(point=None, mouse_button=MouseButton.Left, post_wait=None) staticmethod

Double-Clicks the specified mouse button at the current location.

Parameters:

Name Type Description Default
point Optional[Point]

The position to move to before clicking.

None
mouse_button MouseButton

The mouse button to click. Defaults to the left button, defaults to MouseButton.Left

Left
post_wait Optional[Union[bool, float, Callable[[], None]]]

Optional wait after operation. True=100ms, float=custom seconds, callable=custom function

None
Source code in flaui/core/input.py
@staticmethod
def double_click(
    point: Optional[Point] = None,
    mouse_button: MouseButton = MouseButton.Left,
    post_wait: Optional[Union[bool, float, Callable[[], None]]] = None,
) -> None:
    """Double-Clicks the specified mouse button at the current location.

    :param point:The position to move to before clicking.
    :param mouse_button: The mouse button to click. Defaults to the left button, defaults to MouseButton.Left
    :param post_wait: Optional wait after operation. True=100ms, float=custom seconds, callable=custom function
    """
    CSMouse.DoubleClick(mouse_button.value) if point is None else CSMouse.DoubleClick(
        point.raw_value, mouse_button.value
    )
    Mouse._apply_post_wait(post_wait)

down(mouse_button=MouseButton.Left, post_wait=None) staticmethod

Sends a mouse down command for the specified mouse button.

Parameters:

Name Type Description Default
mouse_button MouseButton

The mouse button to press, defaults to MouseButton.Left

Left
post_wait Optional[Union[bool, float, Callable[[], None]]]

Optional wait after operation. True=100ms, float=custom seconds, callable=custom function

None
Source code in flaui/core/input.py
@staticmethod
def down(
    mouse_button: MouseButton = MouseButton.Left,
    post_wait: Optional[Union[bool, float, Callable[[], None]]] = None,
) -> None:
    """Sends a mouse down command for the specified mouse button.

    :param mouse_button: The mouse button to press, defaults to MouseButton.Left
    :param post_wait: Optional wait after operation. True=100ms, float=custom seconds, callable=custom function
    """
    CSMouse.Down(mouse_button.value)
    Mouse._apply_post_wait(post_wait)

drag(starting_point, ending_point=None, distance_x=None, distance_y=None, mouse_button=MouseButton.Left, post_wait=None) staticmethod

Drags the mouse from starting point to ending point or by distance.

Parameters:

Name Type Description Default
starting_point Point

Starting point of the drag

required
ending_point Optional[Point]

Ending point of the drag (if using point-to-point drag)

None
distance_x Optional[int]

The x distance to drag, + for right, - for left

None
distance_y Optional[int]

The y distance to drag, + for right, - for left

None
mouse_button MouseButton

The mouse button to use for dragging, defaults to MouseButton.Left

Left
post_wait Optional[Union[bool, float, Callable[[], None]]]

Optional wait after operation. True=100ms, float=custom seconds, callable=custom function

None
Source code in flaui/core/input.py
@staticmethod
def drag(
    starting_point: Point,
    ending_point: Optional[Point] = None,
    distance_x: Optional[int] = None,
    distance_y: Optional[int] = None,
    mouse_button: MouseButton = MouseButton.Left,
    post_wait: Optional[Union[bool, float, Callable[[], None]]] = None,
) -> None:
    """Drags the mouse from starting point to ending point or by distance.

    :param starting_point: Starting point of the drag
    :param ending_point: Ending point of the drag (if using point-to-point drag)
    :param distance_x: The x distance to drag, + for right, - for left
    :param distance_y: The y distance to drag, + for right, - for left
    :param mouse_button: The mouse button to use for dragging, defaults to MouseButton.Left
    :param post_wait: Optional wait after operation. True=100ms, float=custom seconds, callable=custom function
    """
    if ending_point is not None:
        CSMouse.Drag(starting_point.raw_value, ending_point.raw_value, mouse_button.value)
    elif distance_x is not None and distance_y is not None:
        CSMouse.Drag(starting_point.raw_value, distance_x, distance_y, mouse_button.value)
    else:
        raise ValueError("`ending_point or (distance_x and distance_y) must be provided to drag the mouse.")
    Mouse._apply_post_wait(post_wait)

drag_horizontally(starting_point, distance, mouse_button=MouseButton.Left, post_wait=None) staticmethod

Drags the mouse horizontally.

Parameters:

Name Type Description Default
starting_point Point

Starting point of the drag

required
distance int

The distance to drag, + for right, - for left

required
mouse_button MouseButton

The mouse button to use for dragging, defaults to MouseButton.Left

Left
post_wait Optional[Union[bool, float, Callable[[], None]]]

Optional wait after operation. True=100ms, float=custom seconds, callable=custom function

None
Source code in flaui/core/input.py
@staticmethod
def drag_horizontally(
    starting_point: Point,
    distance: int,
    mouse_button: MouseButton = MouseButton.Left,
    post_wait: Optional[Union[bool, float, Callable[[], None]]] = None,
) -> None:
    """Drags the mouse horizontally.

    :param starting_point: Starting point of the drag
    :param distance: The distance to drag, + for right, - for left
    :param mouse_button: The mouse button to use for dragging, defaults to MouseButton.Left
    :param post_wait: Optional wait after operation. True=100ms, float=custom seconds, callable=custom function
    """
    CSMouse.DragHorizontally(starting_point.raw_value, distance, mouse_button.value)
    Mouse._apply_post_wait(post_wait)

drag_vertically(starting_point, distance, mouse_button=MouseButton.Left, post_wait=None) staticmethod

Drags the mouse vertically.

Parameters:

Name Type Description Default
starting_point Point

Starting point of the drag

required
distance int

The distance to drag, + for right, - for left

required
mouse_button MouseButton

The mouse button to use for dragging, defaults to MouseButton.Left

Left
post_wait Optional[Union[bool, float, Callable[[], None]]]

Optional wait after operation. True=100ms, float=custom seconds, callable=custom function

None
Source code in flaui/core/input.py
@staticmethod
def drag_vertically(
    starting_point: Point,
    distance: int,
    mouse_button: MouseButton = MouseButton.Left,
    post_wait: Optional[Union[bool, float, Callable[[], None]]] = None,
) -> None:
    """Drags the mouse vertically.

    :param starting_point: Starting point of the drag
    :param distance: The distance to drag, + for right, - for left
    :param mouse_button: The mouse button to use for dragging, defaults to MouseButton.Left
    :param post_wait: Optional wait after operation. True=100ms, float=custom seconds, callable=custom function
    """
    CSMouse.DragVertically(starting_point.raw_value, distance, mouse_button.value)
    Mouse._apply_post_wait(post_wait)

horizontal_scroll(lines, post_wait=None) staticmethod

Simulates horizontal scrolling of the mouse wheel left or right.

Parameters:

Name Type Description Default
lines int

Lines to scroll horizontally

required
post_wait Optional[Union[bool, float, Callable[[], None]]]

Optional wait after operation. True=100ms, float=custom seconds, callable=custom function

None
Source code in flaui/core/input.py
@staticmethod
def horizontal_scroll(lines: int, post_wait: Optional[Union[bool, float, Callable[[], None]]] = None) -> None:
    """Simulates horizontal scrolling of the mouse wheel left or right.

    :param lines: Lines to scroll horizontally
    :param post_wait: Optional wait after operation. True=100ms, float=custom seconds, callable=custom function
    """
    CSMouse.HorizontalScroll(lines)
    Mouse._apply_post_wait(post_wait)

left_click(point, post_wait=None) staticmethod

Performs a left click.

Parameters:

Name Type Description Default
point Optional[Point]

The position to move before clicking.

required
post_wait Optional[Union[bool, float, Callable[[], None]]]

Optional wait after operation. True=100ms, float=custom seconds, callable=custom function

None
Source code in flaui/core/input.py
@staticmethod
def left_click(point: Optional[Point], post_wait: Optional[Union[bool, float, Callable[[], None]]] = None) -> None:
    """Performs a left click.

    :param point: The position to move before clicking.
    :param post_wait: Optional wait after operation. True=100ms, float=custom seconds, callable=custom function
    """
    CSMouse.LeftClick() if point is None else CSMouse.LeftClick(point.raw_value)
    Mouse._apply_post_wait(post_wait)

left_double_click(point, post_wait=None) staticmethod

Performs a left double click.

Parameters:

Name Type Description Default
point Optional[Point]

The position to move before clicking.

required
post_wait Optional[Union[bool, float, Callable[[], None]]]

Optional wait after operation. True=100ms, float=custom seconds, callable=custom function

None
Source code in flaui/core/input.py
@staticmethod
def left_double_click(
    point: Optional[Point], post_wait: Optional[Union[bool, float, Callable[[], None]]] = None
) -> None:
    """Performs a left double click.

    :param point: The position to move before clicking.
    :param post_wait: Optional wait after operation. True=100ms, float=custom seconds, callable=custom function
    """
    CSMouse.LeftDoubleClick() if point is None else CSMouse.LeftDoubleClick(point.raw_value)
    Mouse._apply_post_wait(post_wait)

move_by(delta_x, delta_y, post_wait=None) staticmethod

Moves the mouse by a given delta from the current position.

Parameters:

Name Type Description Default
delta_x int

The delta for the x-axis

required
delta_y int

The delta for y-axis

required
post_wait Optional[Union[bool, float, Callable[[], None]]]

Optional wait after operation. True=100ms, float=custom seconds, callable=custom function

None
Source code in flaui/core/input.py
@staticmethod
def move_by(
    delta_x: int,
    delta_y: int,
    post_wait: Optional[Union[bool, float, Callable[[], None]]] = None,
) -> None:
    """Moves the mouse by a given delta from the current position.

    :param delta_x: The delta for the x-axis
    :param delta_y: The delta for y-axis
    :param post_wait: Optional wait after operation. True=100ms, float=custom seconds, callable=custom function
    """
    CSMouse.MoveBy(delta_x, delta_y)
    Mouse._apply_post_wait(post_wait)

move_to(new_x=None, new_y=None, new_position=None, post_wait=None) staticmethod

Moves the mouse to a new position.

Parameters:

Name Type Description Default
new_x Optional[int]

The new position on x-axis

None
new_y Optional[int]

The new position on y-axis

None
new_position Optional[Point]

The new position for the mouse.

None
post_wait Optional[Union[bool, float, Callable[[], None]]]

Optional wait after operation. True=100ms, float=custom seconds, callable=custom function

None
Source code in flaui/core/input.py
@staticmethod
def move_to(
    new_x: Optional[int] = None,
    new_y: Optional[int] = None,
    new_position: Optional[Point] = None,
    post_wait: Optional[Union[bool, float, Callable[[], None]]] = None,
) -> None:
    """Moves the mouse to a new position.

    :param new_x: The new position on x-axis
    :param new_y: The new position on y-axis
    :param new_position: The new position for the mouse.
    :param post_wait: Optional wait after operation. True=100ms, float=custom seconds, callable=custom function
    """
    if (new_x is not None and new_y is not None) or new_position is not None:
        CSMouse.MoveTo(new_position.raw_value) if new_position is not None else CSMouse.MoveTo(new_x, new_y)
    else:
        raise ValueError(
            "`new_x, new_y or new_position argument needs to be sent for the Mouse to move to a new position`"
        )
    Mouse._apply_post_wait(post_wait)

right_click(point, post_wait=None) staticmethod

Performs a right click.

Parameters:

Name Type Description Default
point Optional[Point]

The position to move before clicking.

required
post_wait Optional[Union[bool, float, Callable[[], None]]]

Optional wait after operation. True=100ms, float=custom seconds, callable=custom function

None
Source code in flaui/core/input.py
@staticmethod
def right_click(point: Optional[Point], post_wait: Optional[Union[bool, float, Callable[[], None]]] = None) -> None:
    """Performs a right click.

    :param point: The position to move before clicking.
    :param post_wait: Optional wait after operation. True=100ms, float=custom seconds, callable=custom function
    """
    CSMouse.RightClick() if point is None else CSMouse.RightClick(point.raw_value)
    Mouse._apply_post_wait(post_wait)

right_double_click(point, post_wait=None) staticmethod

Performs a right double click.

Parameters:

Name Type Description Default
point Optional[Point]

The position to move before clicking.

required
post_wait Optional[Union[bool, float, Callable[[], None]]]

Optional wait after operation. True=100ms, float=custom seconds, callable=custom function

None
Source code in flaui/core/input.py
@staticmethod
def right_double_click(
    point: Optional[Point], post_wait: Optional[Union[bool, float, Callable[[], None]]] = None
) -> None:
    """Performs a right double click.

    :param point: The position to move before clicking.
    :param post_wait: Optional wait after operation. True=100ms, float=custom seconds, callable=custom function
    """
    CSMouse.RightDoubleClick() if point is None else CSMouse.RightDoubleClick(point.raw_value)
    Mouse._apply_post_wait(post_wait)

scroll(lines, post_wait=None) staticmethod

Simulates scrolling of the mouse wheel up or down.

Parameters:

Name Type Description Default
lines int

Lines to scroll

required
post_wait Optional[Union[bool, float, Callable[[], None]]]

Optional wait after operation. True=100ms, float=custom seconds, callable=custom function

None
Source code in flaui/core/input.py
@staticmethod
def scroll(lines: int, post_wait: Optional[Union[bool, float, Callable[[], None]]] = None) -> None:
    """Simulates scrolling of the mouse wheel up or down.

    :param lines: Lines to scroll
    :param post_wait: Optional wait after operation. True=100ms, float=custom seconds, callable=custom function
    """
    CSMouse.Scroll(lines)
    Mouse._apply_post_wait(post_wait)

up(mouse_button=MouseButton.Left, post_wait=None) staticmethod

Sends a mouse up command for the specified mouse button.

Parameters:

Name Type Description Default
mouse_button MouseButton

The mouse button to press, defaults to MouseButton.Left

Left
post_wait Optional[Union[bool, float, Callable[[], None]]]

Optional wait after operation. True=100ms, float=custom seconds, callable=custom function

None
Source code in flaui/core/input.py
@staticmethod
def up(
    mouse_button: MouseButton = MouseButton.Left,
    post_wait: Optional[Union[bool, float, Callable[[], None]]] = None,
) -> None:
    """Sends a mouse up command for the specified mouse button.

    :param mouse_button: The mouse button to press, defaults to MouseButton.Left
    :param post_wait: Optional wait after operation. True=100ms, float=custom seconds, callable=custom function
    """
    CSMouse.Up(mouse_button.value)
    Mouse._apply_post_wait(post_wait)