Loop Processes Action Icon

Loop Processes

Declaration

<AMLOOP TYPE="PROCESSES" RESULTVARIABLE="text" INCLUDE="text" EXCLUDE="text" RESULTDATASET="text">

See Also

Loop | End Loop | Loop Files | Loop Windows | Loop Processes | Loop Expression | Loop Dataset | Loop List | Loop List Control | Loop Processes | Loop Tree Control | Loop Windows | Break

Description

Loops through the file names of the processes (applications) that are currently running on the system. The variable specified is updated with the process file name. With each successive loop, the next process file name is retrieved. Optionally, a dataset can be populated with extended process information. The loop ends after all the process file names have been retrieved or when a Break is encountered.

Practical Usage

Mainly used to perform one or more actions on every process (application) open on the system.

Parameters

General Properties

Property

Type

Required

Default

Markup

Description

Populate Variable with process name

Text

Yes

(Empty)

RESULTVARIABLE="varname"

Specifies an already created variable name that should be populated with the next process name on each successive loop. The variable must be created in an earlier step using the Create Variable action.

Do Not Include Path Information

Yes/No

No

No

KEEPPATHS="yes"

If set to YES, the folder path is removed from the return value so that a file name only (the process name) is returned.

Create and Populate Dataset with extended process information

Text

No

(Empty)

RESULTDATASET="DSName"

The name of a dataset to be created and populated with process data. In addition to the standard dataset fields, this dataset will contain the fields specified below under Notes.

Advanced Properties

Property

Type

Required

Default

Markup

Description

Include Processes

Text

No

(Empty)

INCLUDE="*Explorer"

Indicates a wildcard mask to designate the process names to be included in the loop. Asterisk (*) or question mark (?) can be used as wildcard characters. For example, if *notepad* was specified, the loop would only include processes that include the text notepad in its name. To specify multiple wildcard masks, separate each one with a pipe (|) character (*.txt|*.jpg).

Exclude Processes

Text

No

(Empty)

EXCLUDE="*Explorer"

Indicates a wildcard mask to designate the process names to omit in the loop. Asterisk (*) or question mark (?) can be used as wildcard characters. For example, if *notepad* was specified, the loop would omit processes that include the text notepad in its name. To specify multiple wildcard masks, separate each one with a pipe (|) character (*.txt|*.jpg).

Output List

Text (options)

No

None

SORT="ascending"

Specifies whether a sort order should be applied towards the list of processes before the loop begins. The available options are:

  • Do not sort list (default)

  • Sort the list in ascending alphabetical order

  • Sort the list in descending alphabetical order

Description Properties

The Description tab allows you to customize the text description of any step as it appears in the Task Builder's Steps Pane.

More on setting custom step description

Error Causes Properties

The Error Causes tab allows you to select/omit specific errors that should cause a particular step to fail.

More on Error Causes properties

On Error Properties

The On Error tab 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 a dataset table with the information listed below (assuming the dataset name selected is theDataset):

 

Name

Data Type

Return Value

theDataset.ProcessName

Text

Returns the path and file name of the .exe file of the process.

theDataset.ProcessID

Text

Returns the unique ID of the process.

theDataset.WindowTitle

Text

Returns the title of the main window associated to the process.

theDataset.WindowClass

Text

Returns the class of the process's main window. A window class is a set of attributes that the system uses as a template to create a window.

theDataset.WindowHandle

Number

Returns The handle of the process's main window. A window handle is a code that uniquely identifies the window.

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.

 

Description: This task closes all currently open Notepad processes. In order for this task to work properly, make sure to have one or more instances of Notepad open on the desktop.

 

<!-- Closes all Notepad processes -->

<AMVARIABLE NAME="currentprocess"></AMVARIABLE>

<AMLOOP TYPE="PROCESSES" RESULTVARIABLE="currentprocess" INCLUDE="*notepad.exe" RESULTDATASET="ProcessDataset">

     <AMENDPROCESS PROCESS="%currentprocess%" />

</AMLOOP>

 

↑ Top of Page