Interfacing With Graphics Applications

It is possible to provide keyboard and mouse input to running student graphics applications.

Delay

Delays a number of seconds before the next action is taken. Useful if the results of the previous action may take some time to render.

Fields:

{
  "action" : "delay",
  "seconds" : 1
}

Screenshot

Takes a screenshot of the display. Screenshots are stored as .png files. By default, screenshots are labeled sequentially per test case (e.g. screenshot_0.png), but they may be given custom names using the name field.

Fields:

{
  "action" : "screenshot",
  "name" : "custom_screenshot_name"
}

GIF

Creates an animated gif of the display. By default, gifs are labeled sequentially per test case (e.g. gif_0.gif), but they may be given custom names using the name field.

Fields:

{
  "action" : "gif",
  "seconds" : 5,
  "frames_per_second" : 15,
  "preserve_individual_frames" : false,
  "name" : "custom_gif_name"
}

Type

Types a sequence of keys one or more times with a delay between each repetition. By default, the sequence is typed once with a .1 second delay. Keys within the sequence are pressed sequentially without delay.

Fields:

{
  "action" : "type",
  "delay_in_seconds" : 1,
  "presses" : 5
}

Key

Presses one or more keys. This action may be done over delayed repetitions.

Fields:

{
  "action" : "type",
  "delay_in_seconds" : 1,
  "presses" : 5
}

Click and Drag

The standard version of click and drag starts either at the mouse’s current position or at a position specified by the user. If a mouse button has been specified, that button is pressed down at that position, otherwise, the left mouse button is pressed. The mouse is then moved to coordinates specified by the end position, and the held button is released.

Fields:

{
  "action" : "click and drag",
  "start_x" : 0,
  "start_y" : 0,
  "end_x" : 100,
  "end_y" : 100,
  "mouse_button" : "left"
}

Click and Drag Delta

The delta version of click and drag starts at the current mouse position, clicks the desired mouse button (or left if one isn’t provided) and then moves a specified number of pixels before releasing. The mouse may not leave the window bounds. However, the function is wrapping, so it will repeatedly click and drag until the desired distance has been moved.

Fields:

{
  "action" : "click and drag delta",
  "end_x" : 1000,
  "end_y" : 1000,
  "mouse_button" : "left"
}

Click

Processes a mousedown and a mouseup of the specified mouse button. Defaults to left click.

Fields:

{
  "action" : "click",
  "mouse_button" : "left"
}

Mouse Move

Moves the mouse from its current position to the x and y provided, clamped to the screen. Values are provided in screen coordinates.

Fields:

{
  "action" : "move",
  "end_x" : 100,
  "end_y" : 100
}

Center Mouse

Moves the mouse to the center of the student’s window.

Fields:

{
  "action" : "center"
}

Move Mouse to Origin

Moves the mouse to the origin (upper left) of the student’s window.

Fields:

{
  "action" : "origin"
}