If Window Exists

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. Commonly used to set up conditional steps to be executed if a specified window is opened, closed, focused or in the background.

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.

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}>

Example

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>

See Also: If, If Compare Files, If Folder Exists, If Last Step, If Pixel Exists, If Process Running, If Text Contains, If Windows Exists, End If, End Select/Case, Goto, Label, Select/Case, Else, About Datasets

General Tab

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

If

Text (Options)

Yes

Window Exists

ACTION="close"

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.

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

Window Title Must Be

Text

Yes

(Empty)

a)WINDOWTITLE="Untitled - Notepad"

b)WINDOWTITLE="*Internet 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.

Window Class Must Be

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.

Window Handle Must Be

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.

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 Tab

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 Add and drag the hand icon onto the desired window object. Click OK when finished. Follow the above instructions to add other characteristics.

(Initially, you must drag the hand icon from the General tab to a window/dialog box.)

Advanced Tab

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 Variable with Window Title

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 Variable with Window Class

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 Variable with Window Handle

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.

Description Tab

The Description tab allows you to customize the text description of any step when it appears in the Steps Pane.

More on setting custom step description

Error Causes Tab

The Error Causes tab is part of AWE's Error Handling functionality which allows you to select / omit specific errors that will cause a particular step to fail.

More about error causes

On Error Tab

The On Error tab is part of AWE's Error Handling functionality which allows you to determine what the task should do if a particular step encounters an error.

More about On Error properties

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