1. Starting Guide

<< Click to Display Table of Contents >>

Navigation:  1. Starting Guides >

1. Starting Guide

1.8. Selecting the Application (Topwindow)

Previous Top Next


Starting Guide

 

Selecting the Application

Locating the Topwindow

Choosing the Application: Understanding and Interacting with Windows

 

clip0534

On your command will the robot interact with Applications and windows.

 

How do we instruct a robot to select a specific window for interaction?

 

At first glance, the concept of a 'window' might seem rudimentary, given our daily interactions with them. We routinely open, close, resize, minimize, and maximize windows in conjunction with applications. However, there's more to windows than meets the eye. Let's delve deeper into understanding what windows are and their significance.

 


Exploring Application Windows: The Gateway to Software Interaction

Before we proceed with our discussion on windows, let's take a moment to visually explore a window.

 

graphic

 

The "Sample Apps" subfolder in your installation directory contains a variety of test applications. However, what you're interacting with is not the application itself, but its window. Since we control the application via the window's buttons and controls, it's easy to conflate the two. To delve deeper into the distinction between processes and applications, refer to Chapter 5:   5. Application and PID .


So, what can we do with these application windows? 

Here's a rundown of the various actions you can perform:

 

1.Launch it by starting its associated application.

2.Move it around to adjust the window position on your screen.

3.Resize the window to fit your viewing preference.

4.Minimize it to temporarily remove it from view while keeping it running.

5.Maximize it to occupy the entire screen for a more immersive experience.

6.If it's minimized or maximized, you can "normalize" it back to its original size and position.

7.Close it to terminate the application.

8.Adjust its Z-Position, allowing you to bring it to the forefront or send it behind other windows.

9.Interact with its elements according to their roles, such as pressing a button or adjusting a slider.

Most of these actions can be performed effortlessly with your mouse.

And also the robot can do all of this.

 


 

clip0535

 

Harnessing Advanced Capabilities with the Robot

 

Utilizing the robot provides us with an expanded set of options for interacting with windows. With the robot, we can:

 

1.Disable any window, effectively preventing any interaction with it.

2.If a window is disabled, we can enable it, restoring its functionality.

3.Make the window invisible, hiding it from view without closing it.

4.If a window is invisible, we can make it visible again, bringing it back into view.

5.Change the text displayed in the window.

6.Perform a variety of other actions, depending on the specific type of window we're dealing with.

These advanced capabilities allow us to manipulate and control windows in ways that go beyond standard user interactions.

 


 

clip0537

 

 

Unveiling the Secret of Windows: The Window Handle

 

Now, it's time to share a little-known fact about windows. Consider the analogy of a newborn child. Upon birth, the child is given a unique name that they carry throughout their life. If you wish to call upon the child, you use their name. Similarly, windows receive a unique identifier at their creation, but in their case, it's a number, not a name. Why a number? Because computers process numbers much faster than names.

 

Each window is assigned a unique number, known as the "window handle." This number is guaranteed to be unique, much like a person's name, but it's a numerical value, making it easier for the computer to process. The window handle allows you to interact with the window, much like using a person's name to get their attention.

 

So, if you want to instruct the robot to interact with a specific window, all you need is the window handle. It's unique and concise, making it an efficient way to identify windows.

 

Let's take a look at some examples of window handles before we proceed.

 

graphic

 

The Dynamic Nature of Window Handles

 

Indeed, using the window handle, such as

 

STW.h|65702

 

makes it straightforward to select a specific window for interaction.

It guarantees that you will access the exact window you desire.

 

However, there is a crucial aspect to consider: the lifespan of windows. Each window is created when you start your program and ceases to exist when you close your program or power off your computer. Here lies the challenge: Every time a window is born, it is assigned a new and unique window handle.

 

Knowing this, we must acknowledge that our script,

 

STW.h|65702

 

will not work if we run it again after closing the application and restarting it.

The window handle associated with the desired window will have changed due to the window's new instantiation.

 

Therefore, it is essential to consider the dynamic nature of window handles and adapt our approach accordingly.

But then ...

 


 

clip0536

 

How do we really select a window to deal with?

 

To effectively select a window for manipulation, we must obtain its unique handle. Once we have the window handle, we gain the ability to interact with the window as desired. The process of obtaining the handle involves "locating" the window and determining its handle and position.

 

Fortunately, we do not have to perform this task manually. The robot can handle it internally by retrieving a list of all available windows and selecting the specific window we desire.

 

To achieve this, we provide the robot with a set of window parameters that uniquely identify the desired window. These parameters should remain consistent, regardless of when or where the script is executed.

 

In many cases, we use the window's caption text as a parameter. For example:

 

' Locate the window

STW.t|BCS - Testform

' Store the window handle in the variable $$MYH

HTV.$$MYH

 

When the window becomes available, the robot will locate it and internally store its handle. We can then store the handle in a variable, such as $$MYH. From that point on, whenever we write:

 

STW.h|$$MYH

 

we can be confident that the script will locate the exact window we desire—the window with the handle stored in $$MYH.

If you wish to see the window handle, you can add the following line to the script:

 

' Locate the window

STW.t|BCS - Testform

' Store the window handle in the variable $$MYH

HTV.$$MYH

MBX. The handle is: $$MYH

 

In practice, we often specify multiple parameters for increased reliability. This ensures that we locate the correct window, even if multiple windows share the same caption on the desktop.

 

Some commonly used window parameters include:

 

1.Window class: This parameter specifies the window class, which may look like:
STW.ct|PBWindowClass|BCS - Testform

 

2.Window ID: Please note that the window ID should not be confused with the window handle. The window ID is often a unique and permanent number, but its usability varies depending on the window class. It is advisable to avoid using the window ID, especially if the window class begins with a "t," as in "tnewcheckbox"
 

3.Process ID: You can instruct the robot to select windows only from a known process ID (PID). If your application has only one window associated with its PID, you can write:

STW.p|2320

 

to locate the desired top window, regardless of whether it is a 32-bit or 64-bit application. If multiple windows share the same PID, there is no guarantee which window will be selected, although it is likely to be the topmost window.

 

Therefore, locate a Top-Window best with a combination of these parameters. There are a lot of parameters available, see the

 

The SPR-Editor's recording option and the Installation Recorder InstaRec are valuable tools that simplify the process of locating windows. With their automated functionality, they can intelligently choose the most suitable variant to locate the window, streamlining the window identification process. This feature saves time and effort by automatically determining the appropriate parameters based on the specific window being accessed. Whether you're using the SPR-Editor or the Installation Recorder InstaRec, these tools provide a convenient and efficient way to handle window location in your automation tasks.

 

1. STW. - Decription

 

The next step is, that you learn about Child-Windows and how to locate then in the chapter:

 

7. Locating Child-Windows

 

* the Installation folder is the folder, where you have installed the robot program.