Loop Windows Action

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.

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>

Examples

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

General Tab Parameters

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

Text, Required
MARKUP: RESULTVARIABLE="varname"

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

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

Advanced Tab Parameters

Include windows: 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.

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

Exclude windows: 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.

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

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

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

Create and populate dataset: 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:

  • Title: the window title

  • Class: the window class

  • Handle: the window handle

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

Sorting: 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.

  • do not sort list: The results are left in their natural order and not sorted.

  • ascending: The results sorted in ascending alphabetical order (A-Z).

  • descending: The results sorted in descending alphabetical order (Z-A).

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