Loop Windows Action

Declaration

<AMLOOP TYPE="WINDOWS" RESULTVARIABLE="text [variablename]" ALLOWHIDDEN="yes/no" INCLUDE="text" EXCLUDE="text" SORT="text [options]" WINDOWHANDLEVARIABLE="text [variablename]" RESULTDATASET="DatasetName">
  (block of steps to loop)
</AMLOOP>

See Also

Get Text, Set Text, Check, Select Item, Press, Check Action-Setting Properties

Description

Loops through all of the windows that are currently open on the system. The variable specified is updated with the current window title, and with each successive loop, the next window title is retrieved. The loop ends after all the open windows have been retrieved or when a Break is encountered.

Practical Usage

To perform an action on every window that is open on the system.

Parameters

General Tab

Populate Variable with Window Title

Text, Required
MARKUP: RESULTVARIABLE="varname"

Specifies an already created variable name that should be populated with the next window title on each successive loop.

Include Hidden Windows

Yes/No, Optional, Default: No
MARKUP: ALLOWHIDDEN="yes"

Specifies that invisible (hidden) windows should be included in the loop results.

Advanced Tab

Include Windows

Text, Optional, Default: (blank)
MARKUP: INCLUDE="*Internet Explorer"

Specifies a wildcard mask to designate the titles of windows to be included in the loop. For example, if "*Internet Explorer" was specified, the loop would only include window titles ending with the text Internet Explorer. Use asterisk (*) or question mark (?) as wildcard characters.

Exclude Windows

Text, Optional, Default: (blank)
MARKUP: EXCLUDE="*Internet Explorer"

Specifies a wildcard mask to designate the titles of the windows to be excluded from the loop. For example, if "*Internet Explorer" was specified, the loop would include all window titles except those ending with the text Internet Explorer. Use asterisk (*) or question mark (?) as wildcard characters.

Populate Variable with Window Handle

Text, Optional, Default: (blank)
MARKUP: WINDOWHANDLEVARIABLE="currentwindowhandle"

Specifies an already existing variable to be populated with the current window handle.

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 each of the windows. In addition to the standard dataset fields, the dataset will contain the following:

Sorting

Text [options], Optional, Default: "none"
MARKUP: SORT="ascending"

Specifies whether a sort order should be applied to the values before the loop begins. For example, selecting "ascending" would return the window titles in alphabetical order.

The available options are:

 Notes

Window Dissection™ Technology

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

Click here for more information.

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

Examples

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

<!-- Close all windows containing the text Internet Explorer -->
<AMVARIABLE NAME="currentwindow"></AMVARIABLE>
<<AMLOOP TYPE="WINDOWS" RESULTVARIABLE="currentwindow" WINDOWHANDLEVARIABLE="" INCLUDE="*Internet Explorer">
<AMWINDOWCLOSE WINDOWTITLE="%currentwindow%">
</AMLOOP>

<!-- List all open Word documents -->
<AMVARIABLE NAME="VariableName"></AMVARIABLE>
<AMSPEAK ENGINE="automatic">These are your open documents.</AMSPEAK>
<AMLOOP TYPE="WINDOWS" RESULTVARIABLE="VariableName" INCLUDE="*.doc*" SORT="ascending" RESULTDATASET="DatasetName">
  <AMSPEAK ENGINE="automatic">%VariableName%</AMSPEAK>
</AMLOOP>