SetMousePosition

Positions the mouse pointer by using absolute or relative coordinates. You can use SetMousePosition to position the mouse for selecting objects that do not have accelerator keys and that do not change position.

Syntax

SetMousePosition relativeTo, x[, y]

Argument Description
relativeTo A value indicating the reference point for the specified mouse pointer position.
  0 Coordinates are relative to the upper-left corner of the screen.
  1 Coordinates are relative to the upper-left corner of the active window.
  2 Coordinates are relative to the current pointer position.
  5 Coordinates are relative to the upper-left corner of the window interior (area within the window borders).
  3 The x-coordinate is one of nine mapped positions relative to the screen.
  4 The x-coordinate is one of nine mapped positions relative to the active window.
  6 The x-coordinate is one of nine mapped positions relative to the window interior (area within the window borders).
x A value indicating the x-coordinate for the mouse position. Value must be an integer. If relativeTo is 1, 2, or 5, x is in pixels and positive values move the pointer right. If relativeTo is 3, 4 or 6, x must be a number between 0 and 8 corresponding to one of nine mapped positions as follows:
  8   1   5
4   0   2
7   3   6
y A value indicating the y-coordinate for the mouse position, in pixels. Value must be an integer. Positive values move the pointer down. If the value of relativeTo is 3, 4 or 6, do not include a value for y.

Example

This instruction positions the mouse pointer relative to the upper-left corner of the active window, 300 pixels to the right and 200 down.

SetMousePosition 1, 300, 200

Notes

  • To select objects, use SetMousePosition followed by a ButtonClick command.
  • Target only objects that are always in the same position.
  • If the specified coordinate values would place the pointer off the screen, Dragon displays an error message or positions the pointer as close as possible to the targeted position.