If Window Exists Action Icon

If Window Exists

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

Else | End If | End Select/Case | Goto | If | If Compare Files | If File Exists | If Folder Exists | If Last Step | If Pixel Exists | If Process Running | If Text Contains | If Windows Exists | Label | Select/Case

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

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

Parameters

General Properties

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)

  1. WINDOWTITLE="Untitled - Notepad"

  2. 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 Properties

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 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. More on the fields that this dataset creates can be found below under Notes.

Description Properties

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 Properties

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

More about error causes properties

On Error Properties

The On Error tab is part of AutoMate'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

Notes

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.

 

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

Window Dissection™ Technology

This action contains a subset of Network Automation's unique "Window Dissection Technology".

Click here for more information

Example

NOTE: The code below can be copied and pasted directly into the Steps pane 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>

 

↑ [Top of Page]