Book demo Start trial

DESKTOP UI AUTOMATION - Lesson 6: Controlling multiple windows

  • How to move and capture between desktop applications
  • How to move data between applications in multiple cycles
  • How to use the “Use UI Windows” block to control the active windows in the flow

Back to desktop UI automation training

You will learn:

  • How to move and capture between desktop applications
  • How to move data between applications in multiple cycles
  • How to use the “Use UI Windows” block to control the active windows in the flow

Back to desktop UI automation training

In this lesson we will look at how to control the flow of applications and windows, and especially how you can move back and forth between 2 or more open applications. We will investigate how we can use the “Use UI Windows” block to control which window is active at any given point in the flow, including how we can use existing flow elements from the individual windows to change the active window.

TRANSCRIPT

Welcome to lesson 6 on desktop UI automation in LEAPWORK

In this lesson we will look more into working with multiple applications in a flow.

In the previous lesson we saw how easy it is to move between applications, e.g.
opening the LEAPWORK demo application, clicking an email link and continuing the flow in Outlook.

The reason its simple is that LEAPWORK always operates on the active window.
If our flow starts in one window,
then opens the next window/application,
and then finishes the flow it's very straight forward and intuitive.

But what if we want to start in Application A
then move to Application B,
and then go back to application A again - maybe to read or write
some data to or from Application B,
and then go to Application B again. This could happen a number of times.

Well then we need to control which window is the active window as part of the flow,
and this is what we will look more at right now.

In the LEAPWORK demo application we want to read all the email addresses
from the contact person and write it into a notepad document - one email at a time.
This means we need to move the focus - or the active window - between the Demo Application
and the notepad window where we write the emails in.

We start out with opening the Demo Application and doing the normal login.
Then we add yet another Start Application and specify "notepad.exe".
Notepad is in the SYSTEM PATH in windows, so it’s enough to just specify the name of the exe file.

Let's run this simple flow.

(Automation case runs)

To find the e-mail addresses we will add a Find UI Element block, which we have seen
in the previous lessons. Notepad is the active window at this stage of the flow,
because it opened as the last window,
So we need to tell the flow to activate the Demo Application window before executing the Find UI Element block, otherwise it will try to find the list of email addresses in the notepad application.

To activate a specific window we add a "Use UI Window" block.
This block is used for setting focus in the right window at the right time.
In this case we want to set focus in the Demo Application, so we click Capture
and select the Demo Application window. Pretty simple!

With the focus now back in the Demo Application, we can capture an email address.
We open the Strategy Editor to change the conditions
to match all contact persons and click Save.

I select "All" in the "Use occurrence" property to iterate all email-addresses,
and add a Get UI Text block to the "Found element" property
to extract the email address from the individual contact persons.
The Get UI Text block will give us the email-address as a text that we can
paste in the notepad document. To paste it in we need to set focus
in the notepad application again, so we add yet another Use UI Window block.

We could have used the same approach and simply just captured the notepad window,
but for the sake of the demo, we will use the "Element" option in the "Use UI Window" block.
In order to use this, we can connect any element that is part of the window we want to activate
to the "Source element" property.
This means that if we had used a Find UI Element to capture a button or similar in the notepad
application, we could have connected this element to the property.
In this case we can use the "Window" property on the Start Application that was used when notepad
was started.
With the focus back in notepad, we can now use a Type Text to simply insert the text followed
by a new line - an ENTER. To do this we connect the "text found" to the "Add Field", which
automatically generates a new field, that we can use in the "Text Value" field.
We add the field and activate Capture to insert an ENTER, by simply pressing the ENTER key.
Remember to deactivate the Capture functionality.
The last thing with this block is to set the type speed to fast to speed up the process.

So just to summarize before we run the entire case:
We open the demo application followed by opening a notepad document.
We then set the focus back in the Demo Application using a Use UI Window and use a Find UI Element
to iterate all the contact persons. For each iteration we:
read the email-address,
set focus back in to notepad,
and inserts the email address.

Let's close the open applications and run the automation case from the start.

As we can see, the email addresses are added to the notepad document one by one.
Let's just stop it here.

In this video we looked at how you can use the "Use UI Window" block to control
which window is the active window at any given time. This is important because
LEAPWORK will always trigger the building block on the active window.

We saw how we moved between the LEAPWORK Demo application and a notepad document,
Reading email addresses from the demo application and inserting them into the notepad document
One by one.