Integrate WinAutomation with UI flows
Table of contents:
In my previous post First steps to start using WinAutomation with UI flows I have guided you through installation and troubleshooting of WinAutomation. However, since this tool became a part of the Microsoft’s RPA landscape, the important question is: how to integrate it with UI flows and existing Power Automate processes? Let me show you my approach.
Trigger WinAutomation from UI flows
According to Microsoft Docs (source: https://docs.microsoft.com/en-us/power-automate/ui-flows/create-processes), the best way to trigger WinAutomation process is to call Command Line Console using UI flows and then use command to trigger WinAutomation process. The command should follow the below pattern:
"%programfiles%\WinAutomation\WinAutomationController.exe" /start "/My Processes/MyAutomationName"
Where /My Processes/MyAutomationName
part is simply a location of your process inside the processes’ folders structure. For the below example:
the command to trigger flow is going to be:
"%programfiles%\WinAutomation\WinAutomationController.exe" /start "/My Processes/Tests/Contoso Recorder"
Passing input parameters
To pass in input parameters after the execution path there should be added a list of values, surrounded by quotes, separated by spaces, eg.:
"%programfiles%\WinAutomation\WinAutomationController.exe" /start "/My Processes/Tests/Contoso Recorder" "param 1" "param 2" "1244" "param 3"
Then in the process user should use action: Get Command Line Arguments which will create a table of the values, that later can be assigned to variables or used inside the process:
You can later call those values by using the below expression:
%CommandLineArguments[0]%
Where [0] is the index of the argument in the list from the command line, eg.:
This way is a very reliable method of triggering the WinAutomation process. I recommend it.
How to pass outcome to UI flows?
Microsoft Documentation recommends displaying response data using a “Display Message” action (it will popup an alert) and then building a second UI flows, that is being triggered after the first one completes work and waits certain moment of time. After waiting, it should read data from message.
I think this way is highly unreliable, due to fact that WinAutomation execution can take sometimes more time than the wait action time takes, or that the Message window target data will be different from the one stored in UI flows action and in the end – getting response will fail.
Also, this way passing multiple values back can be difficult.
My recommended approach
What I recommend is to split your process in two:
- Triggering WinAutomation
- Getting data from WinAutomation
The second process should be triggered using Web Request action, and WinAutomation, once completes the run, should simply send response to the created endpoint URL:
Working solution
Watch in my latest screencast how to integrate UI flows with WinAutomation:
I hope this post will help you doing your next projects using WinAutomation and the whole PowerPlatform! If you have any questions, leave them below 🙂