Skip to main content

Robot Task Activities - Mouse​

The Mouse activities click, double-click, move the mouse and press or release mouse buttons on a UI element or at a fixed screen position.

The Mouse category in the activity list, with Click, Double Click, Mouse Move and Mouse Key

Unless set to use a fixed screen position, all four activities find the target element first and fail if it is not found within WaitForElement.

Finding the element​

Click Click to select an element on the activity to pick the target in the UI and fill in the search properties: move the mouse over the element, hold down Ctrl and click. The search properties are in the Properties pane, under Find Element:

  • ProcessName: the name of the process that owns the window. Required
  • WindowTitle: the title of the window to search in. Supports the wildcards *, ? and #. Default: * (any window)
  • Name, ClassName and AutomationId: the element's name, class name and automation ID. At least one is required
  • Text: the element's text. Supports the wildcards *, ? and #
  • WindowHandle: the handle of the window, when it is known. Default: "0"
  • WaitForElement (under Utils): how long to wait for the element, in milliseconds. Default: "10000"

Inside an Attach Window or Get Active Window activity, the element is searched for in that window.


Click​

Finds the element and clicks it.

The Click activity with the Click to select an element link

  • OffsetX and OffsetY: where to click, relative to the element. With "0", the activity clicks the center of the element. Default: "0"
  • ClickManually: click the screen position in CursorPointX and CursorPointY instead of the element. Default: cleared
  • CursorPointX and CursorPointY: the screen position used when ClickManually is checked. Default: "0"
  • MouseButton: the mouse button to use. Default: "Left"
  • PressedKeys: keys held down during the click, separated by commas, for example LControl or Shift

If the element is off screen, the activity gives its window and the element focus before clicking. If no click position can be calculated, it invokes the element instead, and fails if the element does not support that. If a name in PressedKeys is not a known key name, the activity fails. Use the key names that the Press Key virtual keyboard or Detect fills in.


Double Click​

Finds the element and double-clicks it. The properties are the same as for Click.


Mouse Move​

Finds the element and moves the mouse to it.

  • OffsetX and OffsetY: where to move to, relative to the element. With "0", the mouse moves to the center of the element
  • UseManual: move to the screen position in CursorPointX and CursorPointY instead of the element. Default: cleared
  • HoverTime: the wait in milliseconds after the mouse arrives, so that hover menus and tooltips can appear. Default: "300"

Mouse Key​

Finds the element and presses or releases a mouse button on it. Check ClickManually to act on a fixed screen position instead.

The Mouse Key activity with the Click to select an element link and the Key and Status fields

  • Key: the mouse button, for example "Left", "Right" or "Middle". Default: "Left"
  • Status: the button state to send: "Down" or "Up". Default: "Down"

Pair a "Down" and an "Up" activity to build actions a single click cannot, such as drag and drop: press "Down" on the source element, use Mouse Move to move to the target, then release with "Up".


Tips​

  • Prefer element-based clicks over ClickManually. Fixed positions stop working when a window is moved or resized, or when the Task runs at a different screen resolution
  • To click somewhere other than the center of a control, use OffsetX and OffsetY rather than fixed positions
  • For links and buttons on a web page, use the Web Macro Click Element activity instead. It finds elements by CSS selector or XPath rather than by screen position
  • For a standard control such as a button or check box, the Controls Invoke activity is often more reliable than a simulated click, because it does not depend on the element being visible on screen