Skip to main content
Version: 6.5

Understanding WinApp Recorder Implementation

Overview

To improve the robustness, maintainability, and flexibility of Script Recorder, the following changes took place in v6.5:

  • The existing automation library has been replaced with FlaUI.

  • XPath matching has been made more flexible. Previously, the full sequence of element descriptors had to be provided, and every part had to match exactly. Now you can omit steps or use wildcards, making element lookup less rigid and easier to maintain.

  • A new IAutomationElement abstraction replaces the former IAutomatableComponent, reducing bloat and decoupling it from the Engine.

  • A more stable foundation for creating reliable and reproducible automation scripts has been established.

  • Script Recorder can now record multiple applications at once, regardless of the specified target application. For example, if you set Calculator as a target when creating a new application script, you can launch and record Calculator. However, you can also record any other window present on the desktop, such as Microsoft Word.

This page describes the inventory of methods used by Script Recorder and XPath changes. For information on how to use WinApp Recorder, see Using the WinApp Recorder.

Inventory of Methods (Generated by Script Recorder)

FindAutomationElement Methods

New FindAutomationElement methods have been added to the Recorder. These methods allow recording across multiple applications, rather than being limited to a single target application.

The MainWindow is still populated with the target application window for compatibility with existing methods.

Note: When using FindByInformation or FindByXpathOrInformation without providing window information, the search traverses all windows on the desktop, which may result in slower performance in some scenarios.

Method: FindAutomationElementByXPath(…)
DescriptionFinds anAutomationElement that matches the specified XPath expression. The entire element sequence must match for the element to be considered found. You can omit ancestor or window information to make the search more flexible, or include it to improve performance.
ReturnsAn AutomationElement that implements the IAutomationElement interface.
XPath Language ChangesThere is a change in the XPath syntax between the old and new methods. For more details, see the XPath Query Changes.
Parameters:
XPathThe XPath query used to locate the automation element. Must match exactly one element for a successful result.
timeoutThe maximum time, in milliseconds, to wait for the element to be found. Must be greater than or equal to zero.

A FindAllVariant variant of the method can also be generated manually. For details, see Appendix.

Method: FindAutomationElementByInformation(…)
DescriptionFinds an AutomationElement by its properties, without using information about ancestor elements. This method is useful in scenarios where the element hierarchy may change frequently. It provides the most flexible search approach; however, this flexibility may result in slower performance. A new optimization improves performance by splitting the element search into two steps:
  1. First, it locates the window via XPath.
  2. Then, it finds the desired element using FindByInformation, starting from that window, substantially narrowing the search scope.
Example (Before optimization): var buttonNine0 = FindAutomationElementByInformation("num9Button", "Button", "Nine", "Button", 5, continueOnError:false); Example (After optimization): var buttonNine0 = FindAutomationElementByXPath("/Window[@ClassName=\"ApplicationFrameWindow\"][@Name=\"Calculator\"]", 5, continueOnError:false).FindAutomationElementByInformation("num9Button", "Button", "Nine", "Button", 5, continueOnError:false); This optimization is configurable in the Recorder UI. For details, see Using the WinApp Recorder.
ReturnsA list of AutomationElement objects that implement the IAutomationElement interface.
Remarks
Search RootThe old Engine required window information to locate elements. The new method performs searches from the Desktop as the root. Because ancestor and window information are omitted, the search covers all elements on the Desktop. As an optimization, you can configure the element search to first attempt to locate the window.
Parameters
AutomationIdThe automation ID of the element to find. Can be null or empty to ignore this property.
classNameThe element's class name to find. Can be null or empty to ignore this property.
nameThe name of the element to find. Can be null or empty to ignore this property.
controlTypeThe control type of the element to find. Can be null or empty to ignore this property.
timeoutThe maximum time, in milliseconds, to wait for the element to be found. Must be greater than or equal to zero.

A FindAll variant of the method can also be generated manually. For details, see Appendix.

Method: FindAutomationElementByXPathOrInformation(…)
DescriptionFinds an automation element by using the specified XPath expression. If no match is found, the method attempts to locate the element by matching automation properties such as automation ID, class name, name, and control type. This approach first uses a strict, performant search strategy (findByXpath) and then falls back to a more flexible property-based search (findByInformation) if metadata in the XPath chain has changed or is no longer reliable.
ReturnsAutomationElement that implements the IAutomationElement contract
Remarks:
Search RootFindByInformation previously required window information to locate elements. The new method performs searches from the Desktop as the root, so you do not need to provide window information. This increases flexibility, but because it traverses all windows on the Desktop, performance may be slower in some scenarios. FindByXpath, by contrast, follows a specific set of breadcrumbs from the Desktop, making it considerably faster. In Win365 scenarios, window metadata (such as title or class name) can change between recording and execution. For example, if the document moves or the window title differs. Hiding window information ensures that scripts continue to work even when window details vary. For instance, if a script is recorded on one document window but executed when only a different window is open, it will succeed when window information is omitted.
XPath Language ChangesThere is a change in the XPath syntax between the old and new methods. For details, see XPath Query Changes.
Parameters:
XPathThe XPath expression used to locate the automation element. If null or empty, the search uses the provided automation properties instead.
AutomationIdThe automation ID of the element to find. Used if the XPath expression is not successful. Can be null or empty to ignore this property.
classNameThe element's class name to find. Used if the XPath expression is not successful. Can be null or empty to ignore this property.
nameThe name of the element to find. Used if the XPath expression is not successful. Can be null or empty to ignore this property.
controlTypeThe control type of the element to find. Used if the XPath expression is not successful. Can be null or empty to ignore this property.
timeoutThe maximum time, in milliseconds, to wait for the element to be found. Must be greater than or equal to zero.

This method provides a FindAll variant that returns a list of elements instead of a single element. Unlike the single-element version, it does not throw an exception when multiple elements are found.

Note: A FindAll command is not currently generated automatically by Script Recorder. Script Recorder uses Find[single]ElementByXXXX, a method only available for manual use. For details, see Appendix.

In addition to element search methods, the interface provides the following methods. These methods cover user interactions within a window environment, such as clicks and keyboard input.

Method Name Description
ClickPerforms a click at the specified element’s location (as defined by its bounding rectangle). The mouse pointer may not move directly over the element, but the click action is still executed on the requested element.
Move Mouse To CenterPerforms the mouse move from its initial location to the center of the specified element.
Move Mouse Relative To CoordinatesPerforms the mouse move from its initial location to the specified coordinates relative to the current element’s location. In other words, the movement is not based on the global pixel location, but on the pixel location within the element’s bounding rectangle. These coordinates are captured during recording.
Right ClickPerforms a right-click at the specified element’s location (as defined by its bounding rectangle). The mouse pointer may not move directly over the element, but the click action is still executed on the requested element.
Double ClickPerforms a double-click at the specified element’s location (as defined by its bounding rectangle). The mouse pointer may not move directly over the element, but the click action is still executed on the requested element. The “delta” (the amount of time between clicks) used to register a double-click is based on the window's default values.
GetRootWindowAttempts to fetch the containing top-level window for the current element. This allows access to window-specific methods, such as Close().
AsWindowAttempts to convert the current element to a window. The conversion fails if the element does not have a control type of Window.

XPath Query Changes

Script Recorder has transitioned to a standard XPath-style syntax. In the new format, introduced in v6.5:

  • The ControlType is used as the XPath node (tag)

  • All other metadata is expressed as named attributes

/MenuBar/MenuItem[@Name='SpecificName'][@AutomationId : ‘123’][@ClassName='ClassName']

The standardized XPath query language makes each property explicit, readable, and independently matchable. It allows you to perform complex queries and leverage built-in XPath functions to create flexible and resilient selectors.

/MenuBar/MenuItem[@Name='SpecificName'][@AutomationId : ‘123’][Contains(@ClassName, 'Name’)]

or

/MenuBar/MenuItem[@Name='SpecificName'][@AutomationId : ‘123’][Starts-with(@ClassName, 'Name’)]

You can also omit requirements from an element search in two ways: by leaving metadata fields blank or by omitting specific metadata from the query altogether.

Blank metadata: /RandomWindow[@Class, “ “]

Omitted metadata: /RandomWindow________

Finally, the XPath language allows you to exclude entire chains of elements and to search within a specific subsection of elements using the following syntax:

Original Hierarchy:

/Window/Pane/Pane/Pane/Pane/Pane/Pane/Pane/Pane/Pane/Pane/Pane/Document/Group/Button[@Name=\"Sign in\"]

Trimmed Hierarchy:
//Group/Button[@Name=\"Sign in\"]

Note: The first tags don’t enforce any metadata, and Button enforces the Name value to be “Sign in”.

An element search is considered successful when a sequence of elements includes both:

  1. A group node

  2. A button node with the Name property set to "Sign In"

These capabilities provide the following benefits:

  • Partial matches for dynamic values

  • More tolerant element selection

  • Fewer failures caused by minor UI changes

Appendix

FindAll Methods

The following are methods that are not generated by Script Recorder, but can be performed manually.

Method: FindAllAutomationElementByXPath
DescriptionFinds all AutomationElement objects that match the specified property criteria.
ReturnsA list of AutomationElement objects that implement the IAutomationElement interface.
Method: FindAllAutomationElementByInformation(…)
DescriptionFinds all AutomationElement objects that match the specified property criteria.
ReturnsA list of AutomationElement objects that implement the IAutomationElement interface.
Method: FindAllAutomationElementByXPathOrInformation(…)
DescriptionFinds all AutomationElement objects that match the specified XPath expression. If no elements are found, the method attempts to locate matches by automation properties such as automation ID, class name, name, and control type. Use this method when you need to interact with all elements that meet the specified criteria.
ReturnsA list of AutomationElement objects that implement the IAutomationElement interface.