How to RPA – Automating a Desktop App

How to RPA – Automating a Desktop App

QA 0

How to Automate a Desktop Application

To automate any accessible application on Windows, simply repeat Steps 1-4 in this tutorial to first open the app you’d like to automate, and then find and act on each UI Item, while tweaking the Wait delays in between Actions after each test automation run iteration.

Use the AppRobotic UI Item Explorer tool to easily find App and UI Item “Name” and/or “ID” properties and insert them into your bot Action code. Repeat for each App and UI Item until your process is fully automated.

The steps to automate a desktop application and its user interface Items (button/text box/etc.) are:

Python Code:

Step 1. Open a Desktop App

x.RunApplication(r"C:\Windows\System32\win32calc.exe")

Or, if it’s already open, “Get” the application using its ID or Name property (see Finding App & Item “Name” or “ID” Properties section further below):

x.GetApplication("Name", "Calculator")
x.GetApplication("ID", "…")

Running/opening an application also automatically “gets”/attaches to/selects it. If you have multiple applications running on the VM that you’re automating simultaneously, you’d want to use “x.GetApplication” to first re-select the application where you want to perform an Action such as a click.

Step 2. Find the Item (button/textbox/scrollbar) in the App

x.GetItem("Name", "1") # Calculator 1 button
x.GetItem("ID", "131") # Calculator 1 button

or

myCalcButtonOne = x.GetItem("Name", "1")
myCalcButtonOne = x.GetItem("ID", "131")

Doing Step 3 automatically finds the Item in the currently selected application (using x.GetApplication functionality), so if placing the Item object into a variable like myCalcButtonOne isn’t necessary, Step 2 can be skipped.

Putting an Item object into a variable is useful when using Advanced Actions, such as:

x.Click(variableUIItem)

would be:

x.Click(myCalcButtonOne)

Step 3. Perform an Action on the Item

x.ButtonClick("Name", "1") # Click Calculator 1 button

or:

x.ButtonClick("ID", "131") # Click Calculator 1 button

Step 4. Experiment with adjusting Wait timing between Actions

x.Wait(1000) # in milliseconds, i.e. 1 second

Use Wait Actions to slow down the bot as necessary, please see tips on Timing further below.

Most processes can be automated using Actions in the AppRobotic Application, Common Actions, and Timing categories, and occasionally using the Advanced Actions and Macros/Keyboard/Mouse functionality.

Step 5. Repeat

Repeat steps 1 through 4 for each application and UI Item on which you’d like to perform an Action.

Finding App & Item “Name” or “ID” Properties:

1. Open the “UI Item Explorer” tool in AppRobotic Designer.
2. Click the “UIAVerify” button to open it.
3. Focus the desktop application being automated.
4. Click the CTRL key, and mouse hover over the app’s UI Item that you’re identifying.
5. In UIAVerify, on the right-hand side panel, get the UI Item’s AutomationId or Name property by double-clicking into the property field to the right of “Name” or “AutomationId”. Copy/paste the value into the Action code in Step 2 or 3 above.

Tips on Timing and Wait:

Often, when the bot can’t find an application or UI Item, it’s a timing issue. The bot thinks that an application/item is available because the application “returns a success” code, but in fact it’s not yet visible on the screen.

AppRobotic automatically checks for the application or item to become available on the screen when you “x.GetApplication” to find it in the Desktop hierarchy or later ”x.GetItem” to select an item within that application. However, on some applications you might notice that even though something is programmatically available, the VM user interface is still loading the application or item. This depends on the VM RAM, processor speed, and since AWS instances are shared, if there’s some temporary VM slowdown. This could be a delay of only a few milliseconds, but would result in a button not clicking, for example.

For this, we recommend using strategic “x.DoesItemExist” and “x.Wait” Actions throughout your bot, such as right after opening an application or a new screen, and experimenting with the time delays that work best for your applications. This will make your bots more reliable in case the VM slows periodically throughout the day. It’s a balance between bot reliability and speed/how many processes can be automated on the VM.

Summary

In conclusion, to automate any accessible application on Windows, simply repeat Steps 1-4 in this tutorial to first open the app you’d like to automate, and then find and act on each UI Item, while tweaking the Wait delays in between Actions after each test automation run iteration.

Use the AppRobotic UI Item Explorer tool to easily find App and UI Item “Name” and/or “ID” properties and insert them into your bot Action code. Repeat for each App and UI Item until your process is fully automated.