kvm

Keyword definitions for specialised functionality for Keyboard, Mouse and Video-based manipulation.

These keywords rely on VideoInput and Hid libraries to be initialized using the Init keyword. The initialization is platform-specific.

  • Type: RESOURCE

  • Scope: GLOBAL

Keywords

Click ${button} Button

Click a button on the virtual pointer.

Embedded arguments:

  • ${button}: Button to click (LEFT|RIGHT|MIDDLE).

Example

Click LEFT Button

Click ${button} Button On ${destination}

Move the virtual pointer to the destination and click the button.

See Move Pointer to ${destination} for details.

Embedded arguments:

  • ${button}: Button to click (LEFT|RIGHT|MIDDLE).
  • ${destination}: The template or location to click on.

Example

Click LEFT Button On ${CURDIR}/button.png
Click LEFT Button On Continue

Displace ${point} By (${x}, ${y})

Shift a point by the specified displacements along the x and y axes.

Embedded arguments:

  • ${point}: Point to be displaced, as a tuple (x, y).
  • ${x}: Displacement along the x-axis.
  • ${y}: Displacement along the y-axis.

Displaced point, as a tuple (x, y) of integers.

Example

${shifted}=    Displace ${3,3} By (5, 5)

Drag And Drop On ${destination}

Drag and drop the current target (where the pointer is) on a destination.

Embedded arguments:

  • ${destination}: Can be a string, or the path of an image template file representing

the target location to drop on, or a coordinate tuple (x, y) of integers representing the absolute position to drop on. For details please see Walk Pointer To ${destination}.

Positional and named arguments

Name

Type

Default Value

Kind

Required

Documentation

step_distance

16

POSITIONAL_OR_NAMED

No

delay

0.01

POSITIONAL_OR_NAMED

No

Example

Move Pointer To ${CURDIR}/file_icon.png
Drag And Drop On ${CURDIR}/folder_icon.png

Ensure ${destination} Does Not Match

Ensure a given template or string doesn't match within a given timeout and number of attempts. This function is intended to be used like: "This given template or image should, by the end of this time, not be found on the screen."

Embedded arguments:

  • ${destination}: The template or string to match.

This function ensures that the given destination is not found.

Positional and named arguments

Name

Type

Default Value

Kind

Required

Documentation

timeout

2

POSITIONAL_OR_NAMED

No

Example

Ensure ${CURDIR}/error.png Does Not Match    timeout=5

Get Center Of ${region}

Get the center point of a region.

Embedded arguments:

  • ${region}: Rectangular region represented by a dictionary

of integer values for "left", "right", "top", and "bottom" keys.

Center of the region, as a tuple (x, y) of integers.

Example

${regions}=    Match    ${CURDIR}/button.png
${center}=    Get Center Of ${regions}[0]

Get Position Of ${target}

Get a position from an absolute coordinate, image template, or string.

Embedded arguments:

  • ${target}: If ${target} is a tuple (x, y) of integers,

the position will be the absolute position given by the tuple. Otherwise, if ${target} is the path of an image template file, the position will be the center of the first matching template region. ${target} can also be a string, and the position will be the center of the found text.

Absolute position as a tuple (x, y) of integers.

Example

${position}=    Get Position Of ${CURDIR}/button.png
${position}=    Get Position Of Continue

Move Pointer To ${destination}

Move the pointer to an absolute position or image template.

Embedded arguments:

  • ${destination}: Where to move the pointer to. If ${destination}

is a tuple (x, y) of integers, the pointer will move to the absolute position given by the tuple. Otherwise, if ${destination} is the path of an image template file, the pointer will move to the center of the first matching template region. ${destination} can also be a string, and the pointer will move to the center of the found text.

Absolute position of the pointer after the move, as a tuple (x, y) of integers.

Example

Move Pointer To ${CURDIR}/button.png
Move Pointer To Continue

Move Pointer To ${destination} In ${domain}

Move the pointer to an absolute position or image template.

Embedded arguments:

  • ${destination}: Where to move the pointer to. If ${destination}

is a tuple (x, y) of integers, the pointer will move to the absolute position given by the tuple. Otherwise, if ${destination} is the path of an image template file, the pointer will move to the center of the first matching template region. ${destination} can also be a string, and the pointer will move to the center of the found text.

  • ${domain}: Given region or template to search for ${destination} within.

Absolute position of the pointer after the move, as a tuple (x, y) of integers.

Example

Move Pointer To Continue In ${CURDIR}/dialog.png

Move Pointer To (${x}, ${y})

Move the pointer to an absolute position.

Embedded arguments:

  • ${x}: Integer absolute x-coordinate to move the pointer to.
  • ${y}: Integer absolute y-coordinate to move the pointer to.

Example

Move Pointer To (${640}, ${480})

Move Pointer To Proportional (${x}, ${y})

Move the pointer to a destination position given as proportions to the size of the display output.

Embedded arguments:

  • ${x}: Output-relative x-coordinate to move the pointer to.

It must be in the range 0..1, where 0 represents the left edge, and 1 represents the right edge of the output.

  • ${y}: Output-relative y-coordinate to move the pointer to.

It must be in the range 0..1, where 0 represents the top edge, and 1 represents the bottom edge of the output.

Absolute position of the pointer after the move, as a tuple (x, y) of integers.

Example

Move Pointer To Proportional (0.5, 0.5)

Press ${button} Button

Press a button on the virtual pointer.

Embedded arguments:

  • ${button}: Button to press (LEFT|RIGHT|MIDDLE).

Example

Press LEFT Button

Press ${button} Until ${target} Is Highlighted

Move the keyboard highlight of a grid or menu onto the item whose text matches ${target}, then leave it there.

Presses ${button} repeatedly until Is Highlighted Text reports the target as the highlighted item. The highlight is detected with computer vision (Get Highlighted Text), so no template or prior knowledge of the highlight color is needed. Useful for keyboard-only navigation where a pointer is unavailable.

Embedded arguments:

  • ${button}: The key that advances the highlight. A single direction

that wraps around can reach any item, e.g. "Right".

  • ${target}: The text of the item to move the highlight to.
  • ${max_steps} (optional): Maximum number of key presses before

giving up. Default 50.

  • ${settle} (optional): Seconds to wait after each key press for the

screen to update. Default 0.3.

  • ${color_tolerance} (optional): Background color tolerance in

percent for the highlight detection. Default 20.

  • ${partial} (optional): Also match when ${target} is only part of the

highlighted item, instead of requiring the whole item to match. Default False.

The highlight is checked after every key press at log level WARN, so the log only embeds the images of the final check.

Positional and named arguments

Name

Type

Default Value

Kind

Required

Documentation

max_steps

50

POSITIONAL_OR_NAMED

No

settle

0.3

POSITIONAL_OR_NAMED

No

color_tolerance

20

POSITIONAL_OR_NAMED

No

partial

${False}

POSITIONAL_OR_NAMED

No


Press And Wait For Match

Press a key combination and wait for the template to match.

Positional and named arguments

Name

Type

Default Value

Kind

Required

Documentation

keys-combo

POSITIONAL_OR_NAMED

Yes

template

POSITIONAL_OR_NAMED

Yes

timeout

10

POSITIONAL_OR_NAMED

No

tolerance

${DEFAULT_TEMPLATE_MATCHING_TOLERANCE}

POSITIONAL_OR_NAMED

No

Example

${combo}=    Create List    Control_L    s
Press And Wait For Match    ${combo}    ${CURDIR}/save_dialog.png

Press Combo And Match

If the provided template is not already matching, press a key combination until it does.

Positional and named arguments

Name

Type

Default Value

Kind

Required

Documentation

keys-combo

POSITIONAL_OR_NAMED

Yes

template

POSITIONAL_OR_NAMED

Yes

tentatives

1

POSITIONAL_OR_NAMED

No

timeout

2

POSITIONAL_OR_NAMED

No

tolerance

${DEFAULT_TEMPLATE_MATCHING_TOLERANCE}

POSITIONAL_OR_NAMED

No

Example

${combo}=    Create List    Control_L    n
Press Combo And Match    ${combo}    ${CURDIR}/window.png

Press Key And Match

If the provided template is not already matching, press a key until it does.

Positional and named arguments

Name

Type

Default Value

Kind

Required

Documentation

key

POSITIONAL_OR_NAMED

Yes

template

POSITIONAL_OR_NAMED

Yes

tentatives

1

POSITIONAL_OR_NAMED

No

timeout

2

POSITIONAL_OR_NAMED

No

Example

Press Key And Match    Down    ${CURDIR}/menu.png    tentatives=5

Press Keys Until ${target} Is Highlighted

Move the keyboard highlight of a grid or menu onto the item whose text matches ${target}, then leave it there.

Presses each key in ${keys}, in order, stopping as soon as Is Highlighted Text reports the target as the highlighted item. The caller supplies the full sequence of keys needed to reach the target, so no step counting is needed. The highlight is detected with computer vision (Get Highlighted Text), so no template or prior knowledge of the highlight color is needed. Useful for keyboard-only navigation where a pointer is unavailable.

Embedded arguments:

  • ${target}: The text of the item to move the highlight to.
  • ${keys}: The sequence of keys to press, in order, to reach the

target.

  • ${settle} (optional): Seconds to wait after each key press for the

screen to update. Default 0.3.

  • ${color_tolerance} (optional): Background color tolerance in

percent for the highlight detection. Default 20.

  • ${partial} (optional): Also match when ${target} is only part of the

highlighted item, instead of requiring the whole item to match. Default False.

The highlight is checked after every key press at log level WARN, so the log only embeds the images of the final check.

Positional and named arguments

Name

Type

Default Value

Kind

Required

Documentation

keys

POSITIONAL_OR_NAMED

Yes

settle

0.3

POSITIONAL_OR_NAMED

No

color_tolerance

20

POSITIONAL_OR_NAMED

No

partial

${False}

POSITIONAL_OR_NAMED

No


Release ${button} Button

Release a button on the virtual pointer.

Embedded arguments:

  • ${button}: Button to release (LEFT|RIGHT|MIDDLE).

Example

Release LEFT Button

Release Buttons

Release all buttons on the virtual pointer.

Example

Release Buttons

Walk Pointer To ${destination}

Moves the pointer in incremental steps from the current pointer position to an absolute position or image template.

Embedded arguments:

  • ${destination}: Where to walk the pointer to. If ${destination}

is a tuple (x, y) of integers, the pointer will walk to the absolute position given by the tuple. Otherwise, if ${destination} is the path of an image template file, the pointer will walk to the center of the first matching template region. ${destination} can also be a string, and the pointer will move to the center of the found text.

  • ${step_distance} (optional): Size of each step, in pixels.

Default is 16.

  • ${delay} (optional): Time to sleep after each step, in seconds.

Default is 0.01.

Absolute position of the pointer after the walk, as a tuple (x, y) of integers.

Positional and named arguments

Name

Type

Default Value

Kind

Required

Documentation

step_distance

16

POSITIONAL_OR_NAMED

No

delay

0.01

POSITIONAL_OR_NAMED

No

Example

Walk Pointer To ${CURDIR}/button.png

Walk Pointer To (${x}, ${y})

Move the pointer in incremental steps from the current pointer position to an absolute position.

Embedded arguments:

  • ${x}: Integer absolute x-coordinate to walk the pointer to.
  • ${y}: Integer absolute y-coordinate to walk the pointer to.
  • ${step_distance} (optional): Size of each step, in pixels.

Default is 16.

  • ${delay} (optional): Time to sleep after each step, in seconds.

Default is 0.01.

Positional and named arguments

Name

Type

Default Value

Kind

Required

Documentation

step_distance

16

POSITIONAL_OR_NAMED

No

delay

0.01

POSITIONAL_OR_NAMED

No

Example

Walk Pointer To (${640}, ${480})    step_distance=32

Walk Pointer To Proportional (${x}, ${y})

Move the pointer in incremental steps from the current pointer position to a destination position given as proportions to the size of the display output.

Embedded arguments:

  • ${x}: Output-relative x-coordinate to move the pointer to.

It must be in the range 0..1, where 0 represents the left edge, and 1 represents the right edge of the output.

  • ${y}: Output-relative y-coordinate to move the pointer to.

It must be in the range 0..1, where 0 represents the top edge, and 1 represents the bottom edge of the output.

  • ${step_distance} (optional): maximum distance to move per step horizontally, 0 < step_distance <= 1
  • ${delay} (optional): Time to sleep after each step, in seconds.

Default is 0.01.

Absolute position of the pointer after the walk, as a tuple (x, y) of integers.

Positional and named arguments

Name

Type

Default Value

Kind

Required

Documentation

step_distance

0.01

POSITIONAL_OR_NAMED

No

delay

0.01

POSITIONAL_OR_NAMED

No

Example

Walk Pointer To Proportional (0.5, 0.5)