If Window Exists Action

Declaration

<AMIF ACTION="text" WINDOWTITLE="text" WINDOWCLASS="text" WINDOWHANDLE="number" ALLOWHIDDEN="yes/no" WINDOWHANDLEVARIABLE="text [variablename]" WINDOWCLASSVARIABLE="text [variablename]" WINDOWTITLEVARIABLE="text [variablename]" RESULTDATASET="text" CHILDWINDOW="yes/no" {Also accepts all standard Window Dissection parameters}>

See Also

If Window Exists Action-Setting Properties, Focus Window, Maximize Window, Minimize Window, Restore Window, Hide Window, Unhide Window, Resize Window, Move Window, Wait for Window, End Process

Description

Causes the steps following this action to execute if the specified window is in the specified state. If not, execution follows the next Else or End If action, whichever comes first.

Practical Usage

To set up conditional steps to be executed if a specified window is opened, closed, or focused.

Parameters

General Tab

If

Text, Optional, Default: (exist)
MARKUP: ACTION="close"

Specifies the type of check to be performed.

The available options are:

Window Title Must Be

Text, Required
MARKUP:
a) WINDOWTITLE="Untitled - Notepad"
b) WINDOWTITLE="*Internet Explorer*"

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

Window Class Must Be

Text, Required
MARKUP: WINDOWCLASS="Outlook Express Browser Class"

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

Window Handle Must Be

Number, Optional, Default: 0
MARKUP: WINDOWHANDLE="555735"

Specifies the handle of the window to look for. If set to 0 or omitted, this parameter is ignored.

Window is a Child Window

Yes/No, Optional, Default: NO
MARKUP: CHILDWINDOW="YES"

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

Contents Tab

The Contents tab contains standard window dissection parameters used to describe controls or text inside a window. These parameters are the same on every action that specifies a window and are documented under Window Dissection Parameters.

Advanced Tab

Include Hidden Windows

Yes/No, Optional, Default: NO
MARKUP: ALLOWHIDDEN="YES"

When enabled, specifies that hidden (non-visible) windows should be included in the window search. By default, hidden windows are considered unavailable.

Populate Variable with Window Title

Text [variablename], Optional, Default: (blank)
MARKUP: WINDOWTITLEVARIABLE="MyVariableName"

Specifies the name of an already existing variable that should receive the title of the window that caused the steps to be executed.

Populate Variable with Window Class

Text [variablename], Optional, Default: (blank)
MARKUP: WINDOWCLASSVARIABLE="MyVariableName"

Specifies the name of an already existing variable that should receive the class of the window that caused the steps to be executed.

Populate Variable with Window Handle

Text [variablename], Optional, Default: (blank)
MARKUP: WINDOWHANDLEVARIABLE="MyVariableName"

Specifies the name of an already existing variable that should receive the handle of the window that caused the steps to be executed.

Create and Populate Dataset

Text, Optional, Default: (blank)
MARKUP: RESULTDATASET="DatasetName"

Specifies the name of a dataset to be created and populated with data from the window that caused the steps to be executed. In addition to the standard dataset fields, the dataset will contain the following:

Notes

Custom Description

This action includes the Description tab for entering a custom step description.

More on setting custom step description

Standard Error Handling Options

This action also includes the standard Error Causes and On Error failure handling options/tabs.

More on Error Handling Options

Variables and Expressions

All text fields allow the use of expressions, which can be entered by surrounding the expression in percentage signs (example: %MYVARIABLE%, %Left('Text',2)%). To help construct these expressions, you can open Expression Builder from these fields by pressing F2.

More on variables
More on expressions

More on the expression builder

 Notes

Custom Description

This action includes the Description tab for entering a custom step description.

More on setting custom step description

Standard Error Handling Options

This action also includes the standard Error Causes and On Error failure handling options/tabs.

More on Error Handling Options

Variables and Expressions

All text fields allow the use of expressions, which can be entered by surrounding the expression in percentage signs (example: %MYVARIABLE%, %Left('Text',2)%). To help construct these expressions, you can open Expression Builder from these fields by pressing F2.

More on variables
More on expressions

More on the expression builder

Example

NOTE: The code below can be copied and pasted directly into the Steps pane of the Task Builder.

<AMIF ACTION="focus" WINDOWTITLE="Google - Windows Internet Explorer" WINDOWTITLEVARIABLE="VariableName" RESULTDATASET="DatasetName">
<AMSPEAK ENGINE="automatic">The window is focused.</AMSPEAK>
<AMELSE />
<AMSPEAK ENGINE="automatic">The window is not focused.</AMSPEAK>
</AMIF>