How to find user interface elements using locators and keyboard shortcuts in Windows applications
Available tools for inspecting Windows applications
One way to automate Windows applications is to target UI components with their identifiers. Microsoft recommends Accessibility Insights for viewing the UI automation properties. Legacy tools such as Inspect.exe can also be used.
Inspecting Windows applications with Accessibility Insights
After installing and launching Accessibility Insights for Windows, inspecting Windows applications is straight-forward. Using the Windows Calculator as an example, hovering over the application displays the properties of the UI components.
By default, Accessibility Insights displays only a few properties, including the accessible Name
of the UI component in the DETAILS
pane. In this case, the name of the button is Five
. Using localized names for automation is not the most robust option since the labels change based on Windows language settings.
To see more properties, click on the settings icon and select Include all properties that have values
:
This will include the AutomationId
property. In this case, the value of that property is num5Button
:
You can use the value of the AutomationId
property in your robot script. Here we are using the Click
keyword from the RPA.Windows
library, prefixing the automation ID with id:
:
Accessing UI components and functionality using keyboard shortcuts
If the application supports keyboard shortcuts (see Windows desktop application robot), it is recommended to use those whenever possible.
This is an example of a robot that controls a browser using only the RPA.Windows
library and available keyboard shortcuts.
Robocorp also supports browser automation solutions such as Selenium and Playwright.
See the robot in action:
When all else fails: Image-based locators
Sometimes UI components in windows applications do not have an ID that could be used to target them, or they can not be accessed by keyboard shortcuts. In these cases it is still possible to locate them using image-based locators.
Conclusion
Windows desktop applications can be automated using UI component IDs, keyboard shortcuts, or image-based locators.