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. Mainly used to perform one or more actions on every process (application) open on the system.
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. |
Declaration
<AMLOOP TYPE="PROCESSES" RESULTVARIABLE="text" INCLUDE="text" EXCLUDE="text" RESULTDATASET="text">
Example
This example 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>
See Also: Loop, Loop Files, Loop Windows, Loop Processes, Loop Expression, Loop Dataset, Loop List, Loop List Control, Loop Tree Control
To set Loop Processes properties
In the Available Actions pane, open the Loop folder and double-click the Loop Processes action or drag it into the Steps pane.
In the Populate variable with process name box, select the variable to populate.
If you want to use the file name only, without the path, select Do not include path information.
To populate a dataset with process and window data, enter a name for the dataset in the Create and populate dataset with extended process information box. (Dataset names must be alphanumeric, begin with a letter, and contain no spaces.) The dataset will contain: Process name, Process ID, Main window title, Main window class, and Main window handle.
Click the Advanced tab.
Use either the Include processes or the Exclude processes box to enter all or part of the application file names that you want to include or ignore. If you make an entry in the Include processes box, all processes that do not match your entry will be ignored. If you make an entry in the Exclude processes box, the specified processes will be ignored and all others will be included. You can use asterisk (*) and question mark (?) as wildcard characters. For example * MS* would specify all applications with MS in the file name.
If you want to loop the processes in ascending or descending alphabetical order, make your selection in the Output list box.
To set the Description tab properties, refer to Description Tab Options.
To set the Error Causes and On Error tab properties, refer to Step Error Handling.
When finished, click OK to save settings and close the properties dialog box.
To auto-indent after all steps are added
In the Steps pane, hold down SHIFT and click the first and last steps in the block so that the complete block of steps is selected.
Click Format .
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. |
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. |
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. |
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:
|
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
The Error Causes tab allows you to select/omit specific errors that should cause a particular step to fail.
More on Error Causes 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
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.