Automate

Automate

Make your phone or tablet smarter with automation

Get it on Google Play

Interact

A decision block that interacts with the User Interface (UI) shown on screen.

If the proceed option is set to Immediately, then the action will be performed on the UI elements currently visible on screen, without pausing the fiber. If set to When UI element appeared, then the fiber will pause until the UI element has appeared on screen.

Only use this block as a last resort if there’s no other way of performing the desired automation.

There are two types of interactions:

  • Global actions which can be performed without knowledge of the on-screen UI elements, the proceed option, XPath expression, package and display id input arguments are ignored.
  • Targeted actions which are performed on a specific Android UI element, as selected by evaluating the XPath expression, custom graphics as used in browsers and games may not work. The “context node” (.) is the XML document root element when using proceed Immediately, or an UI element that changed when using proceed When UI element appeared. When passing text as string literal use the xpathEncode function to ensure proper quote character escaping. Use the Record interactions button to locate and generate the XPath expression of an UI element.

The NO path is executed if the action is allowed but failed to be performed, and when the UI element isn’t visible on screen when using proceed Immediately.

Use the App start or App in foreground block to ensure that the correct activity is shown on screen. A delay between sequential interactions may be needed to ensure the UI has been fully loaded and redrawn.

Graphical user interface XML

The UI is represented as an XML document, of the type as specified by the schema:

  • Active window layout — layout of UI components (views) drawn in the currently active or changed window.
  • Display windows — a display with all the windows it show and the layouts thereof. (Android 5+)

Since it includes a lot more data to be processed avoid using the Display windows schema unless access to other windows is required. Enable the Debug logging option in settings to see statistics on processing performance. Use the Inspect user interface button to preview the XML document.

View element

The root of the XML document when using the Active window layout schema, or the contents of an <layout> element otherwise. A view element represents a UI component drawn on screen, it may contain other views (elements) that it draw. The XML element (tag) name is its UI component class name. Attribute availability depends on the type of UI component and Android version.

AttributeValueDescription
@android:checkablebooleanCan display a check mark
@android:checkedbooleanChecked state
@android:choiceModetextChoice behavior for collection (Android 5+)
@android:clickablebooleanReacts to clicks
@android:columnCountnumberColumn count of collection (Android 5+)
@android:contentDescriptiontextAssociated content description
@android:contextClickablebooleanReacts to context clicks (Android 6+)
@android:editablebooleanHas an input method (Android 4.3+)
@android:enabledbooleanAllows interaction
@android:errortextError text (Android 5+)
@android:focusablebooleanCan take focus
@android:focusedbooleanCurrently has focus
@android:hinttextHint text (Android 8+)
@android:idtextIdentifier name (Android 4.3+)
@android:inputTypetextAllowed type of text input, separated by '|' (Android 4.4+)
@android:labelFortextIdentifier name of element it’s a label for (Android 4.3+)
@android:labeledBytextIdentifier name of label element (Android 4.3+)
@android:layout_columnnumberColumn index of collection item (Android 5+)
@android:layout_columnSpannumberColumn span of collection item (Android 5+)
@android:layout_height(number)Height
@android:layout_rownumberRow index of collection item (Android 5+)
@android:layout_rowSpannumberRow span of collection item (Android 5+)
@android:layout_width(number)Width
@android:layout_x(number)Horizontal position on screen
@android:layout_y(number)Vertical position on screen
@android:longClickablebooleanReacts to long clicks
@android:maxnumberMaximum value for range (Android 5+)
@android:maxLengthnumberMaximum length of text input (Android 5+)
@android:minnumberMinimum value for range (Android 5+)
@android:passwordbooleanInput characters displayed as password dots
@android:progressnumberCurrent value of range (Android 5+)
@android:rowCountnumberRow count of collection (Android 5+)
@android:scrollablebooleanCan scroll
@android:selectedbooleanCurrently selected

Window element

A <window> element represents a window shown on a display, it may contain other windows (<window> elements) that it own. It also always contains a single <layout> element that itself contains the view it draws. Attribute availability depends on Android version.

AttributeValueDescription
@android:activebooleanCurrently active
@android:focusedbooleanCurrently has focus
@android:idnumberIdentifier value
@android:layout_height(number)Height
@android:layout_width(number)Width
@android:layout_x(number)Horizontal position on screen
@android:layout_y(number)Vertical position on screen
@android:packageNametextOwner app package
@android:textLocalestextLanguages used, separated by comma (Android 14+)
@android:titletextTitle
@android:windowLayoutnumberZ-order, higher above lower
@android:windowTypetexType of window

Display element

The root of the XML document when using the Display windows schema. The <display> element contain one or more <window> elements, representing all the windows shown on the display, as determined by the display id.

AttributeValueDescription
@android:idnumberIdentifier value
@android:layout_height(number)Height
@android:layout_width(number)Width
@android:layout_x(number)Horizontal position on screen
@android:layout_y(number)Vertical position on screen
@android:labeltextName of display
@android:rotationnumberDegrees of rotation

Record interaction

If the floating record window is unable to record an UI event, e.g. when clicking a button, then it’s likely due to the XML document changing again before the XPath expression can be generated. A workaround is to instead use the search feature (magnifying glass icon) to pick the UI element shown on screen.

The generated XPath expressions may have to be manually modified to work since it’s difficult automatically predetermine how the UI will change as the user interacts with it.

On Android 11+ the record interactions and inspect user interface windows are hidden on system Settings unless the Allow screen overlays on settings option is enable in system Developer settings.

ArgX, ArgY

Some targeted actions take additional input arguments:

  • Move windowargX/argY is screen coordinate number.
  • Next/Previous at movement granularityargX is granularity; 1 for character (default), 2 word, 4 line, 8 paragraph or 16 page. argY is a boolean whether to extend selection (Android 4.3+).
  • Next/Previous HTML elementargX is HTML tag name text, default is "INPUT".
  • Press and holdargX is duration in seconds number, default is 0.
  • Scroll to positionargX/argY is column/row number of item.
  • Set progressargX is progress number value.
  • Set selectionargX/argY is selection start/end, default is to clear selection.
  • Set textargX is text to set, default is to clear text.

Note! Interacting with Automate isn’t permitted, for security reasons. The Close system dialogs action do not work on Android 12+. The Quick settings action may not work prior to Android 6. The Show input method picker action requires the “appear on top of other apps or parts of the screen” privilege on Android 9+, may not work on Android 12. The Show soft input action requires the “appear on top of other apps or parts of the screen” privilege.

Options

  • Proceed — when the fiber should proceed.
  • Record interaction — record new UI element interactions.
  • Recorded interactions — previously recorded interactions.

Input arguments

  • Action — action to perform, default is Inspect.
  • XPath expressionXPath expression for selecting UI element to interact with, only used for targeted actions, default is the currently focused UI element.
  • XML schema — namespace URI (unofficial) for the type of XML document the XPath expression will evaluate, default is Active window layout.
  • Package — package name of the app displaying the UI element, default is any.
  • Display id — id of the display showing the UI element, default is id of the primary display. (Android 11+)
  • ArgX — first generic argument.
  • ArgY — second generic argument.

Output variables

  • Inspected content — variable to assign the text content of the inspected UI element.

Preview

  • Inspect user interface — save a representation of the UI shown on screen as an XML file, then view it.
Note! This documentation is also accessible within the app from Help & feedback menu.