Skip to content

Screen Actions

Screen Actions are actions to interact with the computer screen.

Actions

screen.crop_screen

Takes a screenshot from desired part of the screen.

Parameters:

x - Left most position of the screen to be croped

y - Top most position of the screen to be croped

width - Width of the screen to crop

height - Height of the screen to crop

save_path - Path to save the croped screenshot image

Returns:

screenshot - Image of entire screen

crop - Image of croped area

Exceptions:

This action gives no exception

screen.find_image

Find the best match of template image, from assets, inside the screen and return the position on screen.

Parameters:

template_image - name of the asset image used as template.

threshold (optional) - minimum match to consider that the template was found (default=0.9 - 90%).

screenshot_img (optional) - if the template should be found on a given screen beside on current screen (default=None - take a new screenshot).

Returns:

x - left position of the found image on screen/screenshot_img

y - top position of the found image on screen/screenshot_img

width - width of the found image on screen/screenshot_img

height - height of the found image on screen/screenshot_img

Exceptions:

ImageNotFoundException - if no matching image were found until the timeout is reached

screen.find_image_center

Find the best match of template image, from assets, inside the screen and return the center position of the found image.

Parameters:

template_image - name of the asset image used as template.

threshold (optional) - minimum match to consider that the template was found (default=0.9 - 90%).

screenshot_img (optional) - if the template should be found on a given screen beside on current screen (default=None - take a new screenshot).

Returns:

x - center position from left of the found image on screen/screenshot_img

y - center position from top of the found image on screen/screenshot_img

screen.find_image_multiple

Find all matches of template image, inside the screen and return its position.

Parameters:

template_image - name of the asset image used as template.

threshold (optional) - minimum match to consider that the template was found (default=0.9 - 90%).

screenshot_img (optional) - if the template should be found on a given screen beside on current screen (default=None - take a new screenshot).

overlap_factor (optional) - percentage of overlap to consider the same image. If the overlap between two images is higher than the overlap_factor, the two found images are considered to be the same (default=0.5 - 50%).

Returns:

List of image posisions, with values:

x[num] - left position of the found image on screen/screenshot_img

y[num] - top position of the found image on screen/screenshot_img

width[num] - width of the found image on screen/screenshot_img

height[num] - height of the found image on screen/screenshot_img

length - number of images found

screen.find_image_multiple_center

Find all matches of template image, inside the screen and return its center position.

Parameters:

template_image - name of the asset image used as template.

threshold (optional) - minimum match to consider that the template was found (default=0.9 - 90%).

screenshot_img (optional) - if the template should be found on a given screen beside on current screen (default=None - take a new screenshot).

overlap_factor (optional) - percentage of overlap to consider the same image. If the overlap between two images is higher than the overlap_factor, the two found images are considered to be the same (default=0.5 - 50%).

Returns:

List of image posisions, with values:

x[num] - center position from left of the found image on screen/screenshot_img

y[num] - center position from top of the found image on screen/screenshot_img

length - number of images found

screen.screenshot

Takes a screenshot from entire screen.

Parameters:

This action has no parameters

Returns:

screenshot - Image of entire screen

Exceptions:

This action gives no exception

screen.wait_image

Waits until a matching image apears on the screen.

Parameters:

template_image - name of the asset image used as template.

threshold (optional) - minimum match to consider that the template was found (default=0.9 - 90%).

screenshot_img (optional) - if the template should be found on a given screen beside on current screen (default=None - take a new screenshot).

timeout (optional) - maximum number os seconds to waits for a matching image. If no matching image pears throws a ImageNotFoundException (default=60).

Returns:

x - left position of the found image on screen/screenshot_img

y - top position of the found image on screen/screenshot_img

width - width of the found image on screen/screenshot_img

height - height of the found image on screen/screenshot_img

Exceptions:

ImageNotFoundException - if no matching image were found until the timeout is reached

screen.wait_images

Waits until one of the matching images apear on the screen.

Parameters:

template_image_list - list with name of the asset images used as template.

threshold (optional) - minimum match to consider that the template was found (default=0.9 - 90%).

screenshot_img (optional) - if the template should be found on a given screen beside on current screen (default=None - take a new screenshot).

timeout (optional) - maximum number os seconds to waits for a matching image. If no matching image pears throws a ImageNotFoundException (default=60).

Returns:

image_found- name of the image that were found on screen

x - left position of the found image on screen/screenshot_img

y - top position of the found image on screen/screenshot_img

width - width of the found image on screen/screenshot_img

height - height of the found image on screen/screenshot_img

Exceptions:

ImageNotFoundException - if no matching image were found until the timeout is reached

Usage Example
script.mvn
screen.wait_images(["error-1.png", "error-2.png"])

if $image_found == "error-1.png":
    prompt.alert("Error 1 found on screen")

elif $image_found == "error-2.png":
    prompt.alert("Error 2 found on screen")

screen.wait_image_disapear

Waits until a matching image disapears from the screen.

Parameters:

template_image - name of the asset image used as template.

threshold (optional) - minimum match to consider that the template was found (default=0.9 - 90%).

screenshot_img (optional) - if the template should be found on a given screen beside on current screen (default=None - take a new screenshot).

timeout (optional) - maximum number os seconds to waits for a matching image to disapear, if not throws a TimeoutException (default=60).

Returns:

This action has no return

Exceptions:

TimeoutException - if the matching image still visible after timeout reaches