Mouse

class ahk.mouse.AsyncMouseMixin(mouse_speed=2, mode=None, **kwargs)[source]
async get_mouse_position(mode=None)[source]
property mouse_position
class ahk.mouse.MouseMixin(mouse_speed=2, mode=None, **kwargs)[source]

Provides mouse functionality for the AHK class

__init__(mouse_speed=2, mode=None, **kwargs)[source]
Parameters
  • mouse_speed – default mouse speed

  • mode

  • kwargs

click(*args, **kwargs)[source]

Click mouse button at a specified position. REF: https://www.autohotkey.com/docs/commands/Click.htm

Parameters
  • x

  • y

  • button

  • n – number of times to click the button

  • direction

  • relative

  • blocking

  • mode

Returns

double_click(*args, **kwargs)[source]

Convenience function to double click, equivalent to click with n=2

Parameters
  • args

  • kwargs

Returns

get_mouse_position(mode=None)[source]
mouse_drag(*args, **kwargs)[source]

Click and drag the mouse

Parameters
  • x

  • y

  • from_position – (x,y) tuple of an optional starting position. Current position is used if omitted

  • speed

  • button – The button the click and drag; defaults to left mouse button

  • relative – click and drag to a relative position rather than an absolute position

  • blocking

  • mode

Returns

mouse_move(*args, **kwargs)[source]

REF: https://www.autohotkey.com/docs/commands/MouseMove.htm

Parameters
  • x – the x coordinate to move to. If omitted, current position is used

  • y – the y coordinate to move to. If omitted, current position is used

  • speed – 0 (fastest) to 100 (slowest). Can be a callable or string AHK expression

  • relative – Move the mouse realtive to current position rather than absolute x,y coordinates

  • mode

  • blocking

Returns

property mouse_position
property mouse_speed
mouse_wheel(direction, *args, **kwargs)[source]

Convenience function for ‘clicking’ the mouse wheel in a given direction.

Parameters
  • direction – the string ‘up’ or ‘down’

  • args – args passed to click

  • kwargs – keyword args passed to click

Returns

right_click(*args, **kwargs)[source]

Convenience function clicking right mouse button. Equivalent to click with button='R'

Parameters
  • args

  • kwargs

Returns

wheel_down(*args, **kwargs)[source]

Convenience function for click with wheel down button

Parameters
  • args

  • kwargs

Returns

wheel_up(*args, **kwargs)[source]

Convenience function for click with wheel up button

Parameters
  • args

  • kwargs

Returns

ahk.mouse.resolve_button(button)[source]

Resolve a string of a button name to a canonical name used for AHK script

Parameters

button (str) –

Returns