HighLevel API

class autokey.scripting.highlevel.PatternNotFound[source]

Exception raised by functions

autokey.scripting.highlevel.visgrep(scr: str, pat: str, tolerance: int = 0) int[source]

Usage: visgrep(scr: str, pat: str, tolerance: int = 0) -> int

Visual grep of scr for pattern pat.

Requires xautomation (http://hoopajoo.net/projects/xautomation.html).

Usage: visgrep("screen.png", "pat.png")

Parameters:
  • scr – path of PNG image to be grepped.

  • pat – path of pattern image (PNG) to look for in scr.

  • tolerance – An integer ≥ 0 to specify the level of tolerance for ‘fuzzy’ matches.

Raises:
  • ValueError – Raised if tolerance is negative or not convertable to int

  • PatternNotFound – Raised if pat not found.

  • FileNotFoundError – Raised if either file is not found

Returns:

Coordinates of the topleft point of the match, if any. Raises PatternNotFound exception otherwise.

autokey.scripting.highlevel.get_png_dim(filepath: str) int[source]

Usage: get_png_dim(filepath:str) -> (int)

Finds the dimension of a PNG. :param filepath: file path of the PNG. :returns: (width, height). :raise Exception: Raised if the file is not a png

autokey.scripting.highlevel.mouse_move(x: int, y: int, display: str = '')[source]

Moves the mouse using xte mousemove from xautomation

Parameters:
  • x – x location to move the mouse to

  • y – y location to move the mouse to

  • display – X display to pass to xte

autokey.scripting.highlevel.mouse_rmove(x: int, y: int, display: str = '')[source]

Moves the mouse using xte mousermove command from xautomation

Parameters:
  • x – x location to move the mouse to

  • y – y location to move the mouse to

  • display – X display to pass to xte

autokey.scripting.highlevel.mouse_click(button: int, display: str = '')[source]

Clicks the mouse in the current location using xte mouseclick from xautomation

Parameters:
  • button – Which button signal to send from the mouse

  • display – X display to pass to xte

autokey.scripting.highlevel.mouse_pos()[source]

Returns the current location of the mouse.

Returns:

Returns the mouse location in a list

autokey.scripting.highlevel.click_on_pat(pat: str, mousebutton: int = 1, offset: (<class 'float'>, <class 'float'>) = None, tolerance: int = 0, restore_pos: bool = False) None[source]

Requires imagemagick, xautomation, xwd.

Click on a pattern at a specified offset (x,y) in percent of the pattern dimension. x is the horizontal distance from the top left corner, y is the vertical distance from the top left corner. By default, the offset is (50,50), which means that the center of the pattern will be clicked at.

Parameters:
  • pat – path of pattern image (PNG) to click on.

  • mousebutton – mouse button number used for the click

  • offset – offset from the top left point of the match. (float,float)

  • tolerance – An integer ≥ 0 to specify the level of tolerance for ‘fuzzy’ matches. If negative or not convertible to int, raises ValueError.

  • restore_pos – return to the initial mouse position after the click.

Raises:

PatternNotFound: Raised when the pattern is not found on the screen

autokey.scripting.highlevel.move_to_pat(pat: str, offset: (<class 'float'>, <class 'float'>) = None, tolerance: int = 0) None[source]

See click_on_pat

autokey.scripting.highlevel.acknowledge_gnome_notification()[source]

Moves mouse pointer to the bottom center of the screen and clicks on it.