Edit desktop UI flows

[This topic is pre-release documentation and is subject to change.]

Note

Microsoft Flow is now Power Automate. For more information, see this blog.

This content will be updated to reflect the branding change in the coming days.

Desktop UI flows automate Windows desktop applications. Please refer to the Known issues to learn more about issues you might run into, workarounds for those issues, and scenarios that are not supported in this preview release.

Prerequisites

A desktop UI flow. Create a desktop UI flow now if you don't have one to edit.

Edit actions

Edit actions

You can edit your recording to:

  • Modify the value for actions that support it.
  • Delete a step.
  • Delete the entire recording.
  • Change the order of actions with drag and drop. Do exercise caution with this as it may break the consistency of your recording.

Advanced parameters let you change:

  • The delay after the action is performed. For example, you can add a one second delay by changing PT0S to PT1S. This can be useful when the target application has a slow response time that doesn’t complete before the next step of your UI flow.
  • The selector for the target user interface element.

Add a recording

You may want to record your UI flow in multiple sessions. After you've completed your first recording you can proceed as follows:

  1. Sign into Power Automate.

  2. Select My flows > UI flows(preview).

  3. Select the UI flow that you want to edit.

  4. Select Edit.

  5. Select New step.

    New step

  6. Select Record app from the list of actions.

    Record app

  7. Select Launch recorder.

    Select launch recorder

    The recorder control displays at the top of your screen.

    The recorder-control

  8. Start the app that you want to record.

    Tip

    As your mouse hovers over controls in the app, you'll notice that a blue outline highlights each control. Always wait for the blue highlight before you select a control.

    If the blue highlight doesn't display around the element, it might not be recorded properly.

  9. Select Record from the recorder control.

  10. Perform the steps in the user interface of the app you are recording, and then select Done on the recorder control.

  11. Select Save, and then test your UI flow.

Add a manual action

Once you've recorded an application with at least one action, you can manually add any of the following actions for that application.

Action Comment
Close application
Right click
Send keys Send keys and key combinations, such as CTRL + C.
Left click
Get text Read the text from a user interface element and then use it as an output.
Enter text
Get element enabled Check if a user interface element is enabled or disabled.
Clear element Clear the value in an editable user interface element.
Wait for seconds Wait before continuing to the next step.

Follow these steps to add a manual action:

  1. Sign into Power Automate.

  2. Select My flows > UI flows(preview).

  3. Select the UI flow that you want to edit.

  4. Select Edit.

  5. Select the recording card that contains the steps to which you want to add a new step. The card expands and displays the recorded steps.

    Select recording card

  6. Select Add an action on the recording card, just below the last recorded step. You'll see the list of manual actions listed earlier in the walkthrough.

  7. Select the action you want to add. Here, I've selected Get element enabled, but you can select any action that makes sense for your scenario.

    Select action to add.png

Once the action is added, you will need to set the Selector in the action’s advanced options.

Action advanced options

Set the selector

The selector identifies the user interface element onto which the action is performed during playback. We recommend that you copy/paste this information from a separate step targeting the same user interface element, if possible.

The format of the selector is:

{  
   "type":"WinUIA",
   "parameters":{  
      "elementStack":[  

      ],
      "elementXPath":""
   }
}

You need to provide the data for the the elemementStack and elementXPath fields of the selector element.

Here is an example of what the elemementStack might look like.

Element stack

You can capture the elementXPath using the WinAppDriver UI Recorder.

WAD tool

Remove the first element (everything before /Window) before using the result in elementXPath of the selector.

Test your UI flow to confirm that your selector works correctly.

Use advanced controls

You can incorporate advanced controls such as conditions, switch cases, and terminate actions within your UI flows.

You can perform these advanced operations by performing the following steps on an existing UI flow.

  1. Select the UI flow you have created > More commands (...) > Edit.

  2. Select + > Add an action on the down arrow of UI flow step to which you want to add logic.

    Add an action

  3. Select Built-in, and then select one of the control actions available.

    Built-in

  4. Complete the expression that needs to be evaluated. You may use dynamic content and expressions to evaluate your condition and switch controls. Additionally, you can use any output that's generated from the previous UI flow steps.

    Condition card

Handle error conditions

Unexpected conditions can arise during playback and cause your UI flows to fail. You can use advanced error handling capabilities to create alternate steps when unexpected conditions arise.

Here are the steps to do so.

  1. Sign into Power Automate with your school or work account.

  2. Select My flows > UI flows to display your UI flows.

  3. Select More commands (the three vertical dots for the UI flow you want to edit).

  4. Select Edit.

  5. Select the down arrow that's located immediately before the UI flow step to which you want to add error handling, and then select + (Insert new step).

    In the following image, we're inserting the new step before the PostElementText 1 step. This means that if PostElementText 1 fails, the alternate steps that you define next, run.

    Insert new step image

  6. Select Add a parallel branch.

    Image showing add a parallel branch and other options

  7. Select the action that you want to perform in the parallel branch if there's a failure when the UI flow runs.

    You can select Record app to do a new recording for the parallel branch or select Terminate from the Built-in actions to exit the UI flow exit gracefully if there's a failure.

    Image showing the parallel branch options

    Note

    By default, the action that you add in the parallel branch runs only if the previous step fails. You can select ... on the parallel branch > Configure run after to change the default behavior.

    Image showing the options, including configure run after

  8. From this screen, you can select the condition on which you want the parallel branch to execute. You can select from one of the four options available.

    Image showing the run after options

    Note: You will not be able to save a UI flow that has both the main branch and parallel branch set to execute on the same condition.

Enable coordinate-based playback

Coordinate-based playback uses relative screen coordinate offset as a fallback that helps UI flows find target objects that the default Windows UI automation framework is unable to find during playback.

Here are some of the reasons why the default Windows UI automation framework might not find target objects during playback:

  • The legacy application that you're automating might not use programming technologies that support the Windows UI automation framework.
  • The application or its controls may not have a unique UI automation XPath, name, or IDs.
  • The application has dynamic controls whose names or IDs could change.
  • The application has controls that do not have names, IDs, unique identifiers, etc.

Tip

Use the same scale and resolution and also maximize the target application during recording to improve the accuracy of coordinate-based playback.

Follow these steps after you've recorded a UI flow script:

  1. Expand the step that launches or attaches the application.

    This is usually the first step of the recording script.

  2. Select Show advanced options.

  3. Find Use coordinate playback properties.

  4. Select Yes from the list to enable coordinate-based playback.

Tip

You can enable or disable Use coordinate playback for each application to apply the setting to all steps performed on that application.

Warning

With coordinate-based playback, the automation may select controls that are not part of the target application due to a variety of reasons, for example, when the UI of the target applications changes dramatically.

Next steps