If - Window Exists

Declaration

<AMIF ACTIVITY="window_exists" WINDOWTITLE="text" 
WINDOWCLASS="text" 
WINDOWHANDLE="text" ACCESSIBILITYENGINE="trext (options)" 
ALLOWHIDDEN="YES/NO" WINDOWTITLEVARIABLE="text" 
WINDOWCLASSVARIABLE="text" 
WINDOWHANDLEVARIABLE="text" RESULTDATASET="text">	

Description: Determines the state of a window and returns TRUE or FALSE depending on the outcome. If TRUE, the steps immediately following this step is executed. If FALSE, execution follows the next Else statement. Optionally, this activity populates a dataset with multiple information about the specified process.

IMPORTANT: All If activities must be followed at some point with an End if step to mark the end of the code block that is to be executed if the expression is true. For ease of use, any If activity added to the Steps panel is always followed by an End if activity. This option can be modified via Task Builder Formatting options.

Practical Usage

Commonly used to set up conditional steps to be executed if a specified window is opened, closed, focused or in the background.

General Parameters

The General tab allows you to select the window to watch for. To specify a currently open window, select the window title from the Window Title must be drop-down list or drag the hand icon onto the desired window.

Property

Type

Required

Default

Markup

Description

Condition

Text (Options)

Yes

Window Exists

  1. ACTION="open"

  2. ACTION="close"

  3. ACTION="focus"

  4. ACTION="background"

Specifies the window state to check. The available options are:

  • Window exists - The IF block will be executed if the window exists (or is open)

  • Window does not exist - The IF block will be executed if the window does not exist (or is closed).

  • Window is focused - The IF block will be executed if the window is open and focused (or in the foreground).

  • Window is not focused - The IF block will be executed if the window is open but unfocused (or in the background).

By window title

Text

Yes

(Empty)

  1. WINDOWTITLE="Untitled-Notepad"

  2. WINDOWTITLE="*Explorer*"

Specifies the title of the window to look for. This parameter is not case sensitive and  supports wildcard characters (* and ?). For example "*Internet Explorer*" would include all windows containing Internet Explorer as part of the title.

By window class

Text

No

(Empty)

WINDOWCLASS=

"Outlook Express Browser Class"

Specifies the class of the window to look for. This parameter is not case sensitive and  supports wildcard characters (* and ?). For example "*Explore*" would include all window classes containing Explore. If omitted, this parameter is ignored.

By window handle

Text

No

(Empty)

WINDOWHANDLE="555735"

Specifies the handle of the window to look for. A window handle is a reference for the operating system. It allows system resources to know what you are referring to when it is passed in an API call. If set to 0 or omitted, this parameter is ignored.

Accessibility engine

Text (options)

No

Auto

  1. ACCESSIBILITYENGINE="ie"

  2. ACCESSIBILITYENGINE="active"

  3. ACCESSIBILITYENGINE="java"

Specifies the Active Accessibility engine to use for this activity. Active accessibility is designed to improve interaction, manipulation and accessibility with standard and custom user interfaces (UIs) of an application (or the operating system) by properly identifying UI elements. The available options are:

Auto -

Active -

Jave -

Internet Explorer -

Window is a Child Window

Yes/No

No

No

CHILDWINDOW="YES"

If set to YES, specifies that the window to look for is a child window. This option is useful for Multi-Document Interface (MDI) applications, which include a series of windows contained within one parent window.

Contents

The Contents tab contains standard window dissection parameters used to describe controls or text inside a window. It can be used to define additional windows characteristics used to determine a matching window. These parameters are the same on every action that specifies a window and are documented under Window Dissection Parameters. To specify additional windows characteristics, toggle the option Window must contain the object(s), click the Add button and drag the hand icon onto the desired window object. Click OK when finished. Follow the above instructions to add other characteristics.

Advanced Properties

Property

Type

Required

Default

Markup

Description

Include hidden windows

Yes/No

No

No

ALLOWHIDDEN="YES"

If set to YES, indicates that hidden (non-visible) windows should be included in the window search. By default, hidden windows are considered unavailable.

Populate window title in variable

Text

No

(Empty)

WINDOWTITLEVARIABLE="varName"

The name of an already existing variable that should be populated with the title of the window that caused this step to execute.

Populate window class in variable

Text

No

(Empty)

WINDOWCLASSVARIABLE="varName"

The name of an already existing variable that should be populated with the class of the window that caused this step to execute.

Populate window handle in variable

Text

No

(Empty)

WINDOWHANDLEVARIABLE="varName"

The name of an already existing variable that should be populated with the handle of the window that caused this step to execute.

Create and Populate Dataset

Text

No

(Empty)

RESULTDATASET="DatasetName"

The name of a dataset to be created and populated with data from the window that caused this step to execute. More on the fields that this dataset creates can be found below under Datasets.

Description tab - A custom description can be provided on the Description tab to convey additional information or share special notes about a task step.

Error Causes tab - Specify how this step should behave upon the occurrence of an error. (Refer to Task Builder > Error Causes Tab for details.)

On Error tab - Specify what AWE should do if this step encounters an error as defined on the Error Causes tab. (Refer to Task Builder > On Error Tab for details.)

Datasets

A dataset is a multiple column, multiple row container object. This action creates and populates a dataset with the following fields (rows):

Name

Type

Return Value

theDataset.Title

Text

Returns the title of the window that caused this step to execute.

theDataset.Class

Text

Returns the class of the window that caused this step to execute.

theDataset.Handle

Number

Returns the handle of the window that caused this step to execute.

Example

The sample AML code below can be copied and pasted directly into the Steps panel of the Task Builder.

Description - This example task will determine if a window with the word "Google" in its title is currently open. If it is, a Speak action will speak the words "The window is open." If it is not, the Speak action will speak the words "The window is not open" instead.

<AMIF WINDOWTITLE="*Google*" RESULTDATASET="DatasetName">
<AMSPEAK>The window is open</AMSPEAK>
<AMELSE />
<AMSPEAK>The window is not open</AMSPEAK>
</AMIF>