lackey classes

lackey.Region class

class lackey.Region(*args)[source]

Bases: object

ABORT = 'ABORT'
BB = 211
CREATE_X_DIRECTION_LEFT = 0
CREATE_X_DIRECTION_RIGHT = 1
CREATE_Y_DIRECTION_BOTTOM = 1
CREATE_Y_DIRECTION_TOP = 0
EAST = 220
EAST_MID = 310
LL = 210
MID_BIG = 'MID_HALF'
MID_HORIZONTAL = 'MID_HORZ'
MID_THIRD = 311
MID_VERTICAL = 'MID_VERT'
NORTH = 202
NORTH_EAST = 302
NORTH_MID = 301
NORTH_WEST = 300
PROMPT = 'PROMPT'
RETRY = 'RETRY'
RR = 201
SKIP = 'SKIP'
SOUTH = 212
SOUTH_EAST = 322
SOUTH_MID = 321
SOUTH_WEST = 320
TT = 200
WEST = 221
WEST_MID = 312
above(expand=None)[source]

Returns a new Region above the current region with a height of expand pixels.

Does not include the current region. If range is omitted, it reaches to the top of the screen. The new region has the same width and x-position as the current region.

aboveAt(offset=0)[source]

Returns point in the center of the region’s top side (offset to the top by negative offset)

add(l, r, t, b)[source]
asOffset()[source]

Returns bottom right corner as offset from top left corner

atMouse()[source]
below(expand=None)[source]

Returns a new Region below the current region with a height of expand pixels.

Does not include the current region. If range is omitted, it reaches to the bottom of the screen. The new region has the same width and x-position as the current region.

bottomAt(offset=0)[source]

Returns point in the center of the region’s bottom side (offset to the bottom by offset)

click(target=None, modifiers='')[source]

Moves the cursor to the target location and clicks the default mouse button.

clipRegionToScreen()[source]

Returns the part of the region that is visible on a screen

If the region equals to all visible screens, returns Screen(-1). If the region is visible on multiple screens, returns the screen with the smallest ID. Returns None if the region is outside the screen.

compare(image)[source]

Compares the region to the specified image

contains(point_or_region)[source]

Checks if point_or_region is within this region

containsMouse()[source]
copyTo(screen)[source]
classmethod create(*args)[source]
debugPreview(title='Debug')[source]

Displays the region in a preview window.

If the region is a Match, circles the target area. If the region is larger than half the primary screen in either dimension, scales it down to half size.

delayType()[source]
doubleClick(target=None, modifiers='')[source]

Moves the cursor to the target location and double-clicks the default mouse button.

drag(dragFrom=None)[source]

Starts a dragDrop operation.

Moves the cursor to the target location and clicks the mouse in preparation to drag a screen element

dragDrop(target, target2=None, modifiers='')[source]

Performs a dragDrop operation.

Holds down the mouse button on dragFrom, moves the mouse to dragTo, and releases the mouse button.

modifiers may be a typeKeys() compatible string. The specified keys will be held during the drag-drop operation.

dropAt(dragTo=None, delay=None)[source]

Completes a dragDrop operation

Moves the cursor to the target location, waits delay seconds, and releases the mouse button

exists(pattern, seconds=None)[source]

Searches for an image pattern in the given region

Returns Match if pattern exists, None otherwise (does not throw exception) Sikuli supports OCR search with a text parameter. This does not (yet).

find(pattern)[source]

Searches for an image pattern in the given region

Throws FindFailed exception if the image could not be found. Sikuli supports OCR search with a text parameter. This does not (yet).

findAll(pattern)[source]

Searches for an image pattern in the given region

Returns Match object if pattern exists, empty array otherwise (does not throw exception). Sikuli supports OCR search with a text parameter. This does not (yet).

findAllByRow(target)[source]

Returns an array of rows in the region (defined by the raster), each row containing all matches in that row for the target pattern.

findAllBycolumn(target)[source]

Returns an array of columns in the region (defined by the raster), each column containing all matches in that column for the target pattern.

findAllText(text)[source]

OCR function

findBest(pattern)[source]

Returns the best match in the region (instead of the first match)

findText(text, timeout=None)[source]

OCR function

get(part)[source]

Returns a section of the region as a new region

Accepts partitioning constants, e.g. Region.NORTH, Region.NORTH_WEST, etc. Also accepts an int 200-999: * First digit: Raster (n rows by n columns) * Second digit: Row index (if equal to raster, gets the whole row) * Third digit: Column index (if equal to raster, gets the whole column)

Region.get(522) will use a raster of 5 rows and 5 columns and return the cell in the middle.

Region.get(525) will use a raster of 5 rows and 5 columns and return the row in the middle.

getAutoWaitTimeout()[source]

Returns the time to wait for an image to appear on the screen

getBitmap()[source]

Captures screen area of this region, at least the part that is on the screen

Returns image as numpy array

getBottomLeft()[source]

Return the Location of the bottom left corner of this region

getBottomRight()[source]

Return the Location of the bottom right corner of this region

getCell(row, column)[source]

Returns the specified cell (if a raster is set for the region)

getCenter()[source]

Return the Location of the center of this region

getClipboard()[source]

Returns the contents of the clipboard

Can be used to pull outside text into the application, if it is first copied with the OS keyboard shortcut (e.g., “Ctrl+C”)

getCol(column, numberColumns=None)[source]

Returns the specified column of the region (if the raster is set)

If numberColumns is provided, uses that instead of the raster

getColW()[source]
getCols()[source]
getEvent(name)[source]

Returns the named event.

Removes it from the internal queue.

getEvents()[source]

Returns a list of all events that have occurred.

Empties the internal queue.

getFindFailedResponse()[source]

Returns the current default response to a FindFailed exception

getH()[source]

Get the height of the region

getLastMatch()[source]

Returns the last successful Match returned by find(), exists(), etc.

getLastMatches()[source]

Returns the last successful set of Match objects returned by findAll()

getLastScreenImage()[source]

Gets the last image taken on this region’s screen

getObserveScanRate()[source]

Gets the number of times per second the observe loop should run

getRepeatWaitTime()[source]

Gets the wait time before repeating a search

getRow(row, numberRows=None)[source]

Returns the specified row of the region (if the raster is set)

If numberRows is provided, uses that instead of the raster

getRowH()[source]
getRows()[source]
getScreen()[source]

Return an instance of the Screen object this region is inside.

Checks the top left corner of this region (if it touches multiple screens) is inside. Returns None if the region isn’t positioned in any screen.

getTarget()[source]

By default, a region’s target is its center

getThrowException()[source]

Returns True if an exception will be thrown for FindFailed operations, False otherwise.

getTime()[source]

Returns the elapsed time in milliseconds to find the last match

getTopLeft()[source]

Return the Location of the top left corner of this region

getTopRight()[source]

Return the Location of the top right corner of this region

getTuple()[source]

Returns the shape of the region as (x, y, w, h)

getW()[source]

Get the width of the region

getWaitScanRate()[source]

Get the current scan rate

getX()[source]

Get the x-coordinate of the upper left-hand corner

getY()[source]

Get the y-coordinate of the upper left-hand corner

grow(width, height=None)[source]

Expands the region by width on both sides and height on the top and bottom.

If only one value is provided, expands the region by that amount on all sides. Equivalent to nearby().

hasEvents()[source]

Check whether any events have been caught for this region

hasObserver()[source]

Check whether at least one event is registered for this region.

The observer may or may not be running.

highlight(*args)[source]

Highlights the region with a colored frame. Accepts the following parameters:

highlight([toEnable], [seconds], [color])

  • toEnable (boolean): Enables or disables the overlay
  • seconds (number): Seconds to show overlay
  • color (string): Hex code (“#XXXXXX”) or color name (“black”)
hover(target=None)[source]

Moves the cursor to the target location

inside()[source]

Returns the same object. Included for Sikuli compatibility.

intersection()[source]

Returns a new region that contains the overlapping portion of this region and the specified region (may be None)

isChanged(min_changed_pixels, screen_state)[source]

Returns true if at least min_changed_pixels are different between screen_state and the current state.

isObserving()[source]

Check whether an observer is running for this region

isRasterValid()[source]
isRegionValid()[source]

Returns false if the whole region is not even partially inside any screen, otherwise true

keyDown(keys)[source]

Concatenate multiple keys to press them all down.

keyUp(keys)[source]

Concatenate multiple keys to up them all.

left(expand=None)[source]

Returns a new Region left of the current region with a width of expand pixels.

Does not include the current region. If range is omitted, it reaches to the left border of the screen. The new region has the same height and y-position as the current region.

leftAt(offset=0)[source]

Returns point in the center of the region’s left side (offset to the left by negative offset)

morphTo(region)[source]

Change shape of this region to match the given Region object

mouseDown(button=<Mock id='139888181611664'>)[source]

Low-level mouse actions.

mouseMove(PSRML=None, dy=0)[source]

Low-level mouse actions

mouseUp(button=<Mock id='139888181611664'>)[source]

Low-level mouse actions

moveTo(location)

Change the upper left-hand corner to a new Location

Doesn’t change width or height

nearby(expand=50)[source]

Returns a new Region that includes the nearby neighbourhood of the the current region.

The new region is defined by extending the current region’s dimensions all directions by range number of pixels. The center of the new region remains the same.

observe(seconds=None)[source]

Begins the observer loop (synchronously).

Loops for seconds or until this region’s stopObserver() method is called. If seconds is None, the observer loop cycles until stopped. If this method is called while the observer loop is already running, it returns False.

Returns True if the observer could be started, False otherwise.

observeInBackground(seconds=None)[source]

As Region.observe(), but runs in a background process, allowing the rest of your script to continue.

Note that the subprocess operates on copies of the usual objects, not the original Region object itself for example. If your event handler needs to share data with your main process, check out the documentation for the multiprocessing module to set up shared memory.

offset(location, dy=0)[source]

Returns a new Region offset from this one by location

Width and height remain the same

onAppear(pattern, handler=None)[source]

Registers an event to call handler when pattern appears in this region.

The handler function should take one parameter, an ObserveEvent object (see below). This event is ignored in the future unless the handler calls the repeat() method on the provided ObserveEvent object.

Returns the event’s ID as a string.

onChange(min_changed_pixels=None, handler=None)[source]

Registers an event to call handler when at least min_changed_pixels change in this region.

(Default for min_changed_pixels is set in Settings.ObserveMinChangedPixels)

The handler function should take one parameter, an ObserveEvent object (see below). This event is ignored in the future unless the handler calls the repeat() method on the provided ObserveEvent object.

Returns the event’s ID as a string.

onVanish(pattern, handler=None)[source]

Registers an event to call handler when pattern disappears from this region.

The handler function should take one parameter, an ObserveEvent object (see below). This event is ignored in the future unless the handler calls the repeat() method on the provided ObserveEvent object.

Returns the event’s ID as a string.

paste(*args)[source]

Usage: paste([PSMRL], text)

If a pattern is specified, the pattern is clicked first. Doesn’t support text paths. text is pasted as is using the OS paste shortcut (Ctrl+V for Windows/Linux, Cmd+V for OS X). Note that paste() does NOT use special formatting like type().

resetScreens()[source]

Synonym for resetMonitors

right(expand=None)[source]

Returns a new Region right of the current region with a width of expand pixels.

Does not include the current region. If range is omitted, it reaches to the right border of the screen. The new region has the same height and y-position as the current region.

rightAt(offset=0)[source]

Returns point in the center of the region’s right side (offset to the right by offset)

rightClick(target=None, modifiers='')[source]

Moves the cursor to the target location and clicks the right mouse button.

saveLastScreenImage()[source]

Saves the last image taken on this region’s screen to a temporary file

saveScreenCapture(path=None, name=None)[source]

Saves the region’s bitmap

setActive(name)[source]

Activates an inactive event type.

setAutoWaitTimeout(seconds)[source]

Specify the time to wait for an image to appear on the screen

setBottomLeft(loc)[source]

Move this region so its bottom left corner is on loc

setBottomRight(loc)[source]

Move this region so its bottom right corner is on loc

setCenter(loc)[source]

Move this region so it is centered on loc

setCols(columns)[source]

Sets the number of columns in the raster (if rows have not been initialized, set to 1 as well)

setFindFailedHandler(handler)[source]

Set a handler to receive FindFailed events (instead of triggering an exception).

setFindFailedResponse(response)[source]

Set the response to a FindFailed exception in this region.

Can be ABORT, SKIP, PROMPT, or RETRY.

setH(h)[source]

Set the height of the region

setImageMissingHandler(handler)[source]

Set a handler to receive ImageMissing events (instead of triggering an exception).

setInactive(name)[source]

The specified event is ignored until reactivated or until the observer restarts.

setLocation(location)[source]

Change the upper left-hand corner to a new Location

Doesn’t change width or height

setObserveScanRate(scan_rate)[source]

Set the number of times per second the observe loop should run

setROI(*args)[source]

Set Region of Interest (same as Region.setRect())

setRaster(rows, columns)[source]

Sets the raster for the region, allowing sections to be indexed by row/column

setRect(*args)[source]

Sets the rect of the region. Accepts the following arguments:

setRect(rect_tuple) setRect(x, y, w, h) setRect(rect_region)

setRepeatWaitTime(wait_time)[source]

Sets the wait time before repeating a search

setRows(rows)[source]

Sets the number of rows in the raster (if columns have not been initialized, set to 1 as well)

setSize(w, h)[source]

Sets the new size of the region

setThrowException(setting)[source]

Defines whether an exception should be thrown for FindFailed operations.

setting should be True or False.

setTopLeft(loc)[source]

Move this region so its top left corner is on loc

setTopRight(loc)[source]

Move this region so its top right corner is on loc

setW(w)[source]

Set the width of the region

setWaitScanRate(seconds=None)[source]

Set this Region’s scan rate

A find op should repeat the search for the given Visual rate times per second until found or the maximum waiting time is reached.

setX(x)[source]

Set the x-coordinate of the upper left-hand corner

setY(y)[source]

Set the y-coordinate of the upper left-hand corner

showScreens()[source]

Synonym for showMonitors

stopObserver()[source]

Stops this region’s observer loop.

If this is running in a subprocess, the subprocess will end automatically.

text()[source]

OCR method. Todo.

type(*args)[source]

Usage: type([PSMRL], text, [modifiers])

If a pattern is specified, the pattern is clicked first. Doesn’t support text paths.

Special keys can be entered with the key name between brackets, as “{SPACE}”, or as Key.SPACE.

union()[source]

Returns a new region that contains both this region and the specified region

wait(pattern, seconds=None)[source]

Searches for an image pattern in the given region, given a specified timeout period

Functionally identical to find(). If a number is passed instead of a pattern, just waits the specified number of seconds. Sikuli supports OCR search with a text parameter. This does not (yet).

waitVanish(pattern, seconds=None)[source]

Waits until the specified pattern is not visible on screen.

If seconds pass and the pattern is still visible, raises FindFailed exception. Sikuli supports OCR search with a text parameter. This does not (yet).

wheel(*args)[source]

Clicks the wheel the specified number of ticks. Use the following parameters:

wheel([PSRML], direction, steps, [stepDelay])

write(text)[source]

Has fancy special options. Not implemented yet.

lackey.Pattern class

class lackey.Pattern(target=None)[source]

Bases: object

Defines a pattern based on a bitmap, similarity, and target offset

debugPreview(title='Debug')[source]

Loads and displays the image at Pattern.path

exact()[source]

Returns a new Pattern with a similarity threshold of 1.0

getFilename()[source]

Returns the path to this Pattern’s bitmap

getImage()[source]
getSimilar()[source]

Returns the current minimum similarity

getTargetOffset()[source]

Returns the target offset as a Location(dx, dy)

isImagePattern()[source]
isValid()[source]
setFilename(filename)[source]

Set the filename of the pattern’s image (and load it)

setImage(img)[source]
similar(similarity)[source]

Returns a new Pattern with the specified similarity threshold

targetOffset(dx, dy)[source]

Returns a new Pattern with the given target offset

lackey.Match class

class lackey.Match(score, target, rect)[source]

Bases: lackey.RegionMatching.Region

Extended Region object with additional data on click target, match score

getScore()[source]

Returns confidence score of the match

getTarget()[source]

Returns the location of the match click target (center by default, but may be offset)

lackey.Screen class

class lackey.Screen(screenId=None)[source]

Bases: lackey.RegionMatching.Region

Individual screen objects can be created for each monitor in a multi-monitor system.

Screens are indexed according to the system order. 0 is the primary monitor (display 1), 1 is the next monitor, etc.

Lackey also makes it possible to search all screens as a single “virtual screen,” arranged according to the system’s settings. Screen(-1) returns this virtual screen. Note that the larger your search region is, the slower your search will be, so it’s best practice to adjust your region to the particular area of the screen where you know your target will be.

Note that Sikuli is inconsistent in identifying screens. In Windows, Sikuli identifies the first hardware monitor as Screen(0) rather than the actual primary monitor. However, on OS X it follows the latter convention. We’ve opted to make Screen(0) the actual primary monitor (wherever the Start Menu/System Menu Bar is) across the board.

capture(*args)[source]

Captures the region as an image

captureForHighlight(*args)

Captures the region as an image

closePrompt()[source]

Not yet implemented

doPrompt(message, obs)[source]

Not yet implemented

getBounds()[source]

Returns bounds of screen as (x, y, w, h)

getCurrentID()[source]

Returns screen ID

getID()

Returns screen ID

getLastScreenImageFromScreen()[source]

Returns the last captured image from this screen

classmethod getNumberScreens()[source]

Get the number of screens in a multi-monitor environment at the time the script is running

classmethod getPrimaryID()[source]

Returns primary screen ID

classmethod getPrimaryScreen()[source]

Returns the primary screen

hasPrompt()[source]

Not yet implemented

newLocation(loc)[source]

Creates a new location on this screen, with the same offset it would have had on the default screen

newRegion(loc, width, height)[source]

Creates a new region on the current screen at the specified offset with the specified width and height.

primaryScreen = 0
resetMonitors()[source]

Recalculates screen based on changed monitor setup

resetPrompt()[source]

Not yet implemented

saveCapture(name, reg=None)[source]

Not yet implemented

selectRegion(text='')[source]

Not yet implemented

classmethod showMonitors()[source]

Prints debug information about currently detected screens

showTarget()[source]

Not yet implemented

userCapture(message='')[source]

Not yet implemented

lackey.Location class

class lackey.Location(x, y)[source]

Bases: object

Basic 2D point object

above(dy)[source]

Get a new location dy pixels vertically above the current location.

below(dy)[source]

Get a new location dy pixels vertically below the current location.

click()[source]
copyTo(screen)[source]

Creates a new point with the same offset on the target screen as this point has on the current screen

doubleClick()[source]
getColor()[source]
getMonitor()[source]

Returns an instance of the Screen object this Location is inside.

Returns the primary screen if the Location isn’t positioned in any screen.

getOffset(loc)[source]

Returns the offset between the given point and this point

getScreen()[source]

Returns an instance of the Screen object this Location is inside.

Returns None if the Location isn’t positioned in any screen.

getTuple()[source]

Returns coordinates as a tuple (for some PlatformManager methods)

getX()[source]

Returns the X-component of the location

getY()[source]

Returns the Y-component of the location

grow(*args)[source]

Creates a region around the given point Valid arguments:

  • grow(wh) - Creates a region centered on this point with a width and height of wh.
  • grow(w, h) - Creates a region centered on this point with a width of w and height of h.
  • grow(Region.CREATE_X_DIRECTION, Region.CREATE_Y_DIRECTION, w, h) - Creates a region with this point as one corner, expanding in the specified direction
hover()[source]
left(dx)[source]

Get a new location dx pixels horizontally to the left of the current location.

move(x, y)

Set the location of this object to the specified coordinates.

moveTo(x, y)

Set the location of this object to the specified coordinates.

offset(dx, dy)[source]

Get a new location which is dx and dy pixels away horizontally and vertically from the current location.

right(dx)[source]

Get a new location dx pixels horizontally to the right of the current location.

setLocation(x, y)[source]

Set the location of this object to the specified coordinates.

translate(dx, dy)[source]

lackey.Mouse class

class lackey.Mouse[source]

Bases: object

Mid-level mouse routines.

LEFT
MIDDLE
RIGHT
WHEEL_DOWN = 0
WHEEL_UP = 1
at()

Gets Location of cursor

buttonDown(button=<Mock id='139888181612304'>)[source]

Holds down the specified mouse button.

Use Mouse.LEFT, Mouse.MIDDLE, Mouse.RIGHT

buttonUp(button=<Mock id='139888181612496'>)[source]

Releases the specified mouse button.

Use Mouse.LEFT, Mouse.MIDDLE, Mouse.RIGHT

click(loc=None, button=<Mock id='139888181612176'>)[source]

Clicks the specified mouse button.

If loc is set, move the mouse to that Location first.

Use button constants Mouse.LEFT, Mouse.MIDDLE, Mouse.RIGHT

down(button=<Mock id='139888181612304'>)

Holds down the specified mouse button.

Use Mouse.LEFT, Mouse.MIDDLE, Mouse.RIGHT

getPos()[source]

Gets Location of cursor

hasMoved()[source]

Checks if mouse was moved since last mouse action

move(loc, yoff=None)[source]

Moves cursor to specified location. Accepts the following arguments:

  • move(loc) - Move cursor to Location
  • move(xoff, yoff) - Move cursor to offset from current location
moveSpeed(location, seconds=0.3)[source]

Moves cursor to specified Location over seconds.

If seconds is 0, moves the cursor immediately. Used for smooth somewhat-human-like motion.

up(button=<Mock id='139888181612496'>)

Releases the specified mouse button.

Use Mouse.LEFT, Mouse.MIDDLE, Mouse.RIGHT

wheel(direction, steps)[source]

Clicks the wheel the specified number of steps in the given direction.

Use Mouse.WHEEL_DOWN, Mouse.WHEEL_UP

lackey.Keyboard class

class lackey.Keyboard[source]

Bases: object

Mid-level keyboard routines. Interfaces with PlatformManager

keyDown(keys)[source]

Accepts a string of keys (including special keys wrapped in brackets or provided by the Key or KeyModifier classes). Holds down all of them.

keyUp(keys)[source]

Accepts a string of keys (including special keys wrapped in brackets or provided by the Key or KeyModifier classes). Releases any that are held down.

type(text, delay=0.1)[source]

Translates a string into a series of keystrokes.

Respects Sikuli special codes, like “{ENTER}”.

lackey.App class

class lackey.App(identifier=None)[source]

Bases: object

Allows apps to be selected by title, PID, or by starting an application directly. Can address individual windows tied to an app.

For more information, see Sikuli’s App documentation.

classmethod close(appName)[source]

Closes the process associated with the specified app.

As a class method, accessible as App.class(appName). As an instance method, accessible as App(appName).close().

classmethod focus(appName)[source]

Searches for exact text, case insensitive, anywhere in the window title.

Brings the matching window to the foreground.

As a class method, accessible as App.focus(appName). As an instance method, accessible as App(appName).focus().

classmethod focusedWindow()[source]

Returns a Region corresponding to whatever window is in the foreground

classmethod getClipboard()[source]

Gets the contents of the clipboard (as classmethod)

getName()[source]

Returns the short name of the app as shown in the process list

getPID()[source]

Returns the PID for the associated app (or -1, if no app is associated or the app is not running)

getWindow()[source]

Returns the title of the main window of the currently open app.

Returns an empty string if no match could be found.

hasWindow()[source]

Returns True if the process has a window associated, False otherwise

isRunning(waitTime=0)[source]

If PID isn’t set yet, checks if there is a window with the specified title.

isValid()[source]
classmethod open(executable)[source]

Runs the specified command and returns an App linked to the generated PID.

As a class method, accessible as App.open(executable_path). As an instance method, accessible as App(executable_path).open().

classmethod pause(waitTime)[source]
classmethod setClipboard(contents)[source]

Sets the contents of the clipboard (as classmethod)

setUsing(params)[source]
waitForWindow(seconds=5)[source]
window(windowNum=0)[source]

Returns the region corresponding to the specified window of the app.

Defaults to the first window found for the corresponding PID.

lackey.Button class

class lackey.Button[source]
CENTER = 1
LEFT = 0
RIGHT = 2

lackey.Key class

class lackey.Key[source]

Key codes for InputEmulation.Keyboard object.

Can be entered directly or concatenated with an existing string, e.g. type(Key.TAB)

ADD = '{ADD}'
ALT = '{ALT}'
BACKSPACE = '{BACKSPACE}'
CAPS_LOCK = '{CAPS_LOCK}'
CMD = '{CMD}'
CTRL = '{CTRL}'
DELETE = '{DELETE}'
DIVIDE = '{DIVIDE}'
DOWN = '{DOWN}'
END = '{END}'
ENTER = '{ENTER}'
ESC = '{ESC}'
F1 = '{F1}'
F10 = '{F10}'
F11 = '{F11}'
F12 = '{F12}'
F13 = '{F13}'
F14 = '{F14}'
F15 = '{F15}'
F16 = '{F16}'
F2 = '{F2}'
F3 = '{F3}'
F4 = '{F4}'
F5 = '{F5}'
F6 = '{F6}'
F7 = '{F7}'
F8 = '{F8}'
F9 = '{F9}'
HOME = '{HOME}'
INSERT = '{INSERT}'
LEFT = '{LEFT}'
META = '{META}'
MINUS = '{MINUS}'
MULTIPLY = '{MULTIPLY}'
NUM0 = '{NUM0}'
NUM1 = '{NUM1}'
NUM2 = '{NUM2}'
NUM3 = '{NUM3}'
NUM4 = '{NUM4}'
NUM5 = '{NUM5}'
NUM6 = '{NUM6}'
NUM7 = '{NUM7}'
NUM8 = '{NUM8}'
NUM9 = '{NUM9}'
NUM_LOCK = '{NUM_LOCK}'
PAGE_DOWN = '{PAGE_DOWN}'
PAGE_UP = '{PAGE_UP}'
PAUSE = '{PAUSE}'
PRINTSCREEN = '{PRINTSCREEN}'
RIGHT = '{RIGHT}'
SCROLL_LOCK = '{SCROLL_LOCK}'
SEPARATOR = '{SEPARATOR}'
SHIFT = '{SHIFT}'
SPACE = '{SPACE}'
TAB = '{TAB}'
UP = '{UP}'
WIN = '{WIN}'

lackey.KeyModifier class

class lackey.KeyModifier[source]

Can be used with type() to modify another key, e.g. type(Key.DELETE, Key.CTRL+Key.ALT)

ALT = '{ALT}'
CMD = '{CMD}'
CTRL = '{CTRL}'
META = '{META}'
SHIFT = '{SHIFT}'
WIN = '{WIN}'

lackey.PlatformManagerWindows class

lackey.PlatformManagerWindows

alias of lackey.PlatformManagerWindows

lackey.Debug class

class lackey.DebugMaster[source]

Bases: object

Used to create the global Debug object

error(message)[source]

Records an Error-level log message

Uses the log path defined by Debug.setUserLogFile(). If no log file is defined, sends to STDOUT

history(message)[source]

Records an Action-level log message

Uses the log path defined by Debug.setUserLogFile(). If no log file is defined, sends to STDOUT

info(message)[source]

Records an Info-level log message

Uses the log path defined by Debug.setUserLogFile(). If no log file is defined, sends to STDOUT

log(level, message)[source]

Records a Debug-level log message Uses the log path defined by Debug.setUserLogFile(). If no log file is defined, sends to STDOUT

off()[source]

Turns off all debugging messages

on(level)[source]

Turns on all debugging messages up to the specified level

0 = None; 1 = User;

setLogFile(filepath)[source]

Defines the file to which output log messages should be sent.

Set to None to print to STDOUT instead.

setLogger(logger_obj)[source]

Sets log handler to logger_obj

setLoggerAction(mthd)[source]

Sends action messages to logger.[mthd]() for handling

setLoggerAll(mthd)[source]

Sends all messages to logger.[mthd]() for handling

setLoggerDebug(mthd)[source]

Sends debug messages to logger.[mthd]() for handling

setLoggerError(mthd)[source]

Sends error messages to logger.[mthd]() for handling

setLoggerInfo(mthd)[source]

Sends info messages to logger.[mthd]() for handling

setLoggerNoPrefix(logger_obj)[source]

Sets log handler to logger_obj

setLoggerUser(mthd)[source]

Sends user messages to logger.[mthd]() for handling

user(message)[source]

Creates a user log (if user logging is turned on)

Uses the log path defined by Debug.setUserLogFile(). If no log file is defined, sends to STDOUT

Note: Does not use Java string formatting like Sikuli. Format your message with Python basestring.format() instead.

lackey.Settings class

class lackey.SettingsMaster[source]

Bases: object

Global settings that Lackey refers to by default

ActionLogs = True
BundlePath = '/home/docs/checkouts/readthedocs.org/user_builds/lackey/envs/latest/bin'
ClickDelay = 0.0
DebugLogs = False
DelayBeforeDrag = 0.3
DelayBeforeDrop = 0.3
DelayBeforeMouseDown = 0.3
ErrorLogs = False
ImagePaths = []
InfoLogs = True
LogTime = False
MinSimilarity = 0.7
MoveMouseDelay = 0.3
OberveMinChangedPixels = 50
ObserveScanRate = 3
OcrDataPath = None
PopupLocation = None
ShowActions = False
SlowMotionDelay = 3
TypeDelay = 0.0
UserLogPrefix = 'user'
UserLogTime = True
UserLogs = True
WaitScanRate = 3
getSikuliVersion()[source]

lackey.FindFailed class

class lackey.FindFailed(event)[source]

Bases: exceptions.Exception

Exception: Unable to find the searched item

Sikuli Convenience Functions

lackey.sleep(seconds)[source]

Convenience function. Pauses script for seconds.

lackey.exit(value)[source]

Convenience function. Exits with code value.

lackey.setShowActions(value)[source]

Convenience function. Sets “show actions” setting (True or False)

lackey.getBundlePath()[source]

Convenience function. Returns the path of the *.sikuli bundle.

lackey.getBundleFolder()[source]

Convenience function. Same as getBundlePath() plus the OS default path separator.

lackey.setBundlePath(path)[source]

Convenience function. Changes the path of the *.sikuli bundle.

lackey.getImagePath()[source]

Convenience function. Returns a list of paths to search for images.

lackey.addImagePath(new_path)[source]

Convenience function. Adds a path to the list of paths to search for images.

Can be a URL (but must be accessible).

lackey.addHTTPImagePath(new_path)[source]

Convenience function. Same as addImagePath().

lackey.getParentPath()[source]

Convenience function. Returns the parent folder of the *.sikuli bundle.

lackey.getParentFolder()[source]

Convenience function. Same as getParentPath() plus the OS default path separator.

lackey.makePath(*args)[source]

Convenience function. Returns a path from a series of path components.

Same as os.path.join.

lackey.makeFolder(*args)[source]

Convenience function. Same as makePath() plus the OS default path separator.

lackey.unzip(from_file, to_folder)[source]

Convenience function.

Extracts files from the zip file fromFile into the folder toFolder.

lackey.popat(*args)[source]

Convenience function. Sets the popup location (currently not used).

lackey.popup(text, title='Lackey Info')[source]

Creates an info dialog with the specified text.

lackey.popError(text, title='Lackey Error')[source]

Creates an error dialog with the specified text.

lackey.popAsk(text, title='Lackey Decision')[source]

Creates a yes-no dialog with the specified text.

lackey.input(msg='', default='', title='Lackey Input', hidden=False)[source]

Creates an input dialog with the specified message and default text.

If hidden, creates a password dialog instead. Returns the entered value.

lackey.inputText(message='', title='Lackey Input', lines=9, width=20, text='')[source]

Creates a textarea dialog with the specified message and default text.

Returns the entered value.

lackey.select(message='', title='Lackey Input', options=None, default=None)[source]

Creates a dropdown selection dialog with the specified message and options

default must be one of the options.

Returns the selected value.

lackey.popFile(title='Lackey Open File')[source]

Creates a file selection dialog with the specified message and options.

Returns the selected file.