mouse — autopy module for working with the mouse

This module contains functions for getting the current state of and controlling the mouse cursor.

Unless otherwise stated, coordinates are those of a screen coordinate system, where the origin is at the top left.

Functions

autopy.mouse.location() -> (float, float)

Returns a tuple (x, y) of the current mouse position.

autopy.mouse.toggle(button: Button=None, down: bool)

Holds down or releases the given mouse button in the current position. Button can be LEFT, RIGHT, MIDDLE, or None to default to the left button.

autopy.mouse.click(button: Button=None, delay: float=None)

Convenience wrapper around toggle() that holds down and then releases the given mouse button. By default, the left button is pressed.

autopy.mouse.move(x: float, y: float)

Moves the mouse to the given (x, y) coordinate.

Exceptions:
  • ValueError is thrown if the point is out of index.
autopy.mouse.smooth_move(x: float, y: float)

Smoothly moves the mouse to the given (x, y) coordinate in a straight line.

Exceptions:
  • ValueError is thrown if the point is out of index.

Constants

class autopy.mouse.Button
Button:LEFT
Button:RIGHT
Button:MIDDLE