powerautomate

Creating a Desktop Flow - Working with a legacy application

Desktop flows broaden the existing robotic process automation (RPA) capabilities in Power Automate and enable you to automate all repetitive desktop processes. Automating is quicker and easier than ever with the new intuitive Power Automate desktop flow designer using the prebuilt drag-and-drop actions or recording your own desktop flows to run later.

Desktop flows are addressed to essentially everyone who is performing simple or complex rule-based tasks on their workstations. Users at home, small businesses, enterprises, or larger companies can leverage automation capabilities in Power Automate to create flows, interact with everyday tools like email and Excel, or work with modern and legacy applications. Examples of simple and complex tasks you can automate are:

In this Lab

In this lab, we will create a Desktop flow to work with a legacy application that generates invoices.

Task 1

In this task, we will ensure that all pre-requisites to run desktop flows are met.

a. Get Power Apps Developer Plan - This step was completed during Day 1 prerequisites.

b. Install the Power Automate for desktop application - Go to https://powerautomate.microsoft.com/ and sign in with the account that you’re using for the labs.

image

image

image

c. Download and Install the legacy invoicing application provided in the resources of this lab.

image

d. Next, spend some time getting familiar with the Contoso Invoicing app. These steps explore how the Contoso Coffee shop employee manually enters a new invoice record into the company application system when a new invoice is received. This exercise helps you better prepare for the following lab exercises.

Task 2

a. Create a new Desktop flow by clicking on My Flows > Under Desktop Flows > Click + New Desktop Flow > Click Launch App. If you’re presented with a dialog that wants to open Power Automate, select the Always allow checkbox and then select Open Power Automate to open the Power Automate for desktop app.

image

b. When you’re in the Power Automate for desktop app designer, in the search bar in the Actions pane, enter run application and then double-click the Run application action.

image

c. Within the Run application dialog, for the application path parameter, go to and select the location path of the Contoso Invoicing app under Application path. (This action opens the Contoso Invoicing app when you’re running your flow). Usually, you can find this parameter under C:\Program Files (x86)\Contoso, Inc\Contoso Invoicing\LegacyInvoicingApp.exe; however, the path might be different on your computer.

image

d. Select the Save button in the lower-right corner of the dialog. Now you have one action in your flow that opens the Contoso Invoicing app. You can select the Run button to quickly test your flow.

image

Note: Minimize the invoicing application as it is required in the next step in our desktop flow.

e. Now we want to wait for the application to load before the flow does anything else. When you’re in the Power Automate for desktop app designer, in the search bar in the Actions pane, enter wait for window and then double-click the Wait for window.

image

f. In the Wait for window dialog, select Window > Add UI Element >

image

g. Organize the UI Selector and the Contoso Invoicing app windows side by side. Select the Contoso Invoicing app window by clicking CTRL + left click.

image

h. Now you have two actions in your flow that opens the Contoso Invoicing app. You can select the Run button to quickly test your flow.

Note: Minimize the invoicing application as it is required in the next step in our desktop flow.

Task 3

a. Minimize the Contoso Invoicing app manually and then select Recorder.

Tip: Now, you can start recording. We recommend that you get familiar with the following steps until the recording is done. As a result, you can finish the recording in one instance without manually going back and forth. If your first few recordings aren’t acceptable, you can delete the recording afterward by selecting the ellipsis (…) menu and then practice more until you have an acceptable recording.

Tip: To help with the resilience of UI automation playbacks, we recommend that you minimize other apps from your desktop.

image

Note: The action of closing the app hasn’t been recorded for simplicity purposes. The reason is so that you can view the result because the Contoso Invoicing app remains open after you test the desktop flow. In a real-world use case, you can decide whether to record the closing action or not.

Note: By default, the desktop flow launches a new instance of the app whenever it runs. Even if you leave the app open, the next desktop flow run launches another new app window. You can also change this behavior to only attach to an existing app instead of launching another new instance from the portal (more details are provided in the following steps).

b. Within the Power Automate for desktop app, you can view the recorded script of each step. You can edit each step by selecting the ellipsis (…) icon to the right of the title and then by selecting Edit from the options list. You can also double-click each step to view the options list.

Tip: You can also select the ellipsis (…) and then select the Delete option from the list to remove duplicate steps or the entire script.

image

c. You can select the Run icon at the top of the screen to play back and test your flow. Don’t interact with your device during testing. The recording will play back successfully.

d. You can rename UI elements to better match the purpose and define each uniquely by right-clicking on the element, where you can select rename.

e. Select the Save icon in the upper part of the screen to save the desktop flow.

Task 4

In the previous task, you created your first desktop flow that can automate the entering of a new invoice with fixed parameter values for Contoso Invoicing App. However, in reality, your automation should use real input variables instead of fixed values, and you’ll likely need to capture real-time output from the automation running result as well.

In this module, you’ll import a solution and learn how to create and use input and output parameters.

a. Within the Input/output variables section to the right of the screen, in the Variables pane, select the plus (+) icon and then select Input from the options list to add your first input.

image

b. In the New input variable dialog, use these values to set up the first input variable:

- Variable name - Amount
- Data type - Text
- Default value - $500
- External name - Amount
- Description - Amount

image

c. Select the Save button in the lower part of the dialog.

d. Repeat the previous steps to add a second input variable. Use the following values to set up the second input variable:

- Variable name - Contact
- Data type - Text
- Default value - b.friday@wingtipcups.com
- External name - Contact
- Description - Contact email

e. Repeat the previous steps again to create a third input variable. Use the information and these values to fill in the variables within the new, third input and then select Save.

- Variable name - Account
- Data type - Text
- Default value - WingTip Cups
- External name - Account Name
- Description - Account Name

f. After you’ve added and saved all three input variables, select the Save button in the upper part of the screen to save changes that you’ve made within the module so far.

image

g. To the right of the screen, in the Variables pane, in the Input/output variables section, select the plus (+) icon and then select the Output option to add your first output variable. Use these values to set up the first output variable:

- Variable name - InvoiceID
- Data type - Text
- External name - InvoiceID
- Description - InvoiceID

After entering the values for the output variable, select the Save button in the lower part of the dialog.

h. Add an action to set this output. Ensure that the Contoso Invoicing application is still running. Select step 10: End of autogenerated actions using the recorder.

image

i. Go to the Actions pane, search for get details, and then double-click to add Get details of the UI element in window.

image

j. In the Get details of the UI element in window dialog, select the UI element dropdown menu and then select Add UI element.

image

Note: After you’ve selected the Add UI element option, a red rectangle will appear on the screen while you hover the mouse cursor over the different elements.

k. Go to the Contoso Invoicing app. On the Invoice Detail tab, move the mouse cursor over the number in the ID field. Press and hold the Ctrl key on your keyboard and then select the ID number.

image

Note: A different ID number might appear than what’s shown in this exercise.

l. Return to the dialog and select Save. This action will automatically produce a variable called AttributeValue. Double click on this variable and change it to InvoiceID.

m. Set up the steps to use input variable values when you’re running the automation. Select step 5: Edit ‘TextBox’ with ‘WingTip Cups’, and then on the right, select the ellipsis (…) menu. From the options menu, select Edit.

image

image

n. Repeat the previous steps to change the value of Text to fill-in in Step 6 and Step 7 in the desktop flow.

image

o. Now, you’ve completed the process of setting up and using inputs and outputs in your desktop flow. In the next modules, you’ll use those inputs and outputs to pass data values between cloud flows and desktop flows. Next, you can test your flow by selecting the Run icon in the lower part of your screen and then watch the automation run by using the input variable values (default values).