Skip to content

Win Click

Type: win-click  ·  Package: Desktop Activities v1.0.8

Clicks a control in a desktop application: a button, a menu item, a tab, a cell. It is the most common interaction activity on the desktop.

It locates the control by its selector (waiting up to timeout), brings its window to the front and, if the control is scrolled out of view, tries to scroll it into view. Then it clicks according to clickType (see interaction methods):

  • invoke (default), when the control is a button: activates it without moving the mouse. Native Windows buttons (Win32, WinForms) get a queued click, so a button that opens a modal dialog (“Are you sure?”) does not block the activity; the next step can act on that dialog. Other buttons use the UIA Invoke pattern and, if the action takes longer than 3 s (a dialog is open), the activity moves on without waiting for it. In this mode the button is always activated with a normal click, whatever button says.
  • invoke on controls that are not buttons, or mouse: makes a physical mouse click at the control’s current center, with the button set in button.
  • In Java applications the click is always physical, at the actual position of the control located by the Swing bridge.
ParameterTypeDefaultDescription
selectorselector—The element to click.
ParameterTypeDefaultDescription
sessionZoanDesktopSession—Win Attach session. Inside a body it is taken automatically; without a session, the selector must include the window.
buttonstringleftButton: left · right · double (double click).
clickTypestringinvokeMethod: invoke (activates buttons without moving the mouse) · mouse (physical click).
timeoutnumber30000Maximum ms to wait for the element. Empty = the project’s UI timeout or, if not set, 30000.

This activity does not return a value.

MessageCause and fix
Element not found with selector {…}. followed by Diagnostics: …The control did not appear within timeout. Wait first with Win Wait For or check the selector. See common errors.
The element is outside the visible area and could not be scrolled into view, …The control is hidden by its container’s scrolling and could not be brought into view; the click would have landed elsewhere. Add a Win Scroll before it.
The Java control could not be located unambiguously, so nothing was done. …In a Java app there are several identical controls or the bridge cannot see it. Add an anchor or an idx to the selector.
Could not map the Java control's coordinates to the screen …Scaled display (125 %, 150 %) and the Java window could not be measured. Try with 100 % scaling on the robot’s machine.
Win Click selector = (button "Save")
Win Click selector = (row "Invoice 001") button = double clickType = mouse
Win Click selector = (file "report.xlsx") button = right clickType = mouse // context menu

A button that opens a confirmation, and the click on the dialog:

Win Click selector = (button "Delete")
Win Wait For selector = (button "Yes") state = visible
Win Click selector = (button "Yes")
  • Win Type — type into a field.
  • Win Wait For — wait for the control to be ready.
  • Win Check — for checkboxes, regardless of their previous state.