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

mouse.get_pos()

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

mouse.toggle(down, button=LEFT_BUTTON)

Holds down or releases the given mouse button in the current position. button can be LEFT_BUTTON, RIGHT_BUTTON, or CENTER_BUTTON. If no button is given, the left button is defaulted to.

Exceptions:
  • ValueError is thrown if the mouse button is invalid.
mouse.move(x, y)

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

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

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.
mouse.click(button=LEFT_BUTTON)

Convenience wrapper around toggle() that holds down and then releases the given mouse button.

Constants

The following is a list of constants used by this module in order to specify mouse buttons.

mouse.RIGHT_BUTTON

Right mouse button.

mouse.CENTER_BUTTON

Middle mouse button.

mouse.LEFT_BUTTON

Left mouse button.