Window Trigger

Description

Triggers task execution when the specified window opens, closes, is focused, or loses focus.

Practical Usage

Useful in a back office (or unattended) environment to monitor the system for application generated error dialogs. These dialog boxes could be automatically handled when they appear. For example, a notification message could be sent to the system administrator upon the occurrence of an error.

Related Topics  

Parameters

General

This trigger comprises Automate's Window Dissection technology to facilitate the discovery of existing windows and their controls. To select the target window:

  1. Make certain the window is open and in the foreground (in front of all other open windows).
  2. Drag and release the magnifier icon over the window. If the window is supported by this trigger, a green border will appear around it.
  3. Upon releasing the icon, identified window properties are populated onto the editor. These properties can be enabled / disabled or further modified.
Property Type Description
Trigger if/when Options Specifies the window state to monitor. The available options are:
  • Window open (default) - The trigger will fire if / when the specified window opens.
  • Window closed- The trigger will fire if / when the specified window closes.
  • Window focused - The trigger will fire if / when the specified window becomes focused (brought to the foreground).
  • Window not focused - The trigger will fire if / when the specified window loses focus (goes to the background).
Triggers once when the window is first open Yes/No

If enabled, specifies that the action to be performed on the window being monitored will occur only once when that window first opens and ignore other instances (disabled by default). For example, if this trigger is set to wait for Notepad to close, enabling this option tells the trigger to watch for the first instance of Notepad to open and activate only when that first instance closes. If a second instance of Notepad opens and closes before the first instance, that action is ignored.

NOTE: This option is available only if the Trigger if/when parameter is set to Window open.

Triggers once when the window is last closed Yes/No

If enabled, specifies that the action to be performed on the window being monitored will occur only once when that window last closes and ignore other instances (disabled by default). For example, if this trigger is set to wait for Notepad to open, enabling this option tells the trigger to watch for the first instance of Notepad to close and activate only when that first instance opens. If a second instance of Notepad close and opens before the first instance, that action is ignored.

NOTE: This option is available only if the Trigger if/when parameter is set to Window closed.

Hold focus

Yes/No

If enabled, specifies that the focused window that caused the trigger to fire will be kept in the foreground (on top of all other windows), preventing all other windows from stealing focus.

NOTE: This option is available only if the Trigger if/when parameter is set to Window focused.

By window title Text If enabled, specifies the title of the window to monitor. The value is not case sensitive. This parameter supports wildcard characters (that is, * and ?). For example, entering *Internet Explorer* would include all windows containing Internet Explorer (enabled by default).
By window class Text If enabled, specifies the class of the window to monitor. A window class is a set of attributes that the system uses as a template to create a window. Every window is a member of a window class. All window classes are process specific. The value is not case sensitive. This parameter supports wildcard characters (that is, * and ?). For example, entering *Explore* would include all window classes containing Explore (disabled by default).
By window handle Text If enabled, specifies the handle of the window to monitor. A window handle is code that uniquely identifies an open window (disabled by default).
Window is a child window Yes/No

If enabled, specifies that the window to monitor is a child window. A child window is normally a secondary window on screen that is displayed within the main overall window of the application. A child window is a window has the following properties:

  • It has a parent window.
  • It stays always in the parent's client area (cannot be displayed outside)
  • If the parent is moved, the child window is moved in the same way (its position relative to parent's client area doesn't change);
  • it is destroyed when its parent is destroyed.

NOTE: This option is available only if the Trigger if/when parameter is set to Window focused or Window not focused.

Contents

If multiple windows with the same title exists, it may be necessary to use Automate's Object Editor to specify additional criteria, such as unique objects, controls or properties, in order to distinguish one window from another. To identify additional elements, enable Window must contain the following objects, and then click Add to open the Object Editor dialog. Thereafter, do one of the following:

  1. Drag and release the magnifier icon over the desired object or control. The Object properties grid becomes populated with a list of name / value pairs unique to that object. Individual values can be enabled / disabled according to preference.
  2. Click Browse to traverse the list of available objects / controls for the selected window. Select the desired object from the Window contents column, and then click OK. The Object properties grid becomes populated with a list of defined properties unique to that object. Individual values can be enabled or disabled according to preference.

Available object properties are described below:

Property Type Required Default Markup Description
Toolkit Text No (Empty)
  • TOOLKIT=UIAutomation
  • TOOLKIT=WindowsAccessibility
  • TOOLKIT=JavaAccessibility

If enabled, specifies that the toolkit (a set of basic building units for graphical user interfaces) will be examined when determining a matching object. If disabled, the toolkit will be ignored.

The toolkit that appears is based on the Accessibility engine used:

  • UI Automation - UIAutomation
  • Active - WindowsAccessibility
  • Java - JavaAccessibility
  • Internet Explorer - WindowsAccessibility
Type Text No (Empty) TYPE=PushButton If enabled, specifies that the object's type (that is, Button, Checkbox, Trackbar) will be examined when determining a matching object. If disabled, the type will be ignored.
Class Text No (Empty) CLASS=SysTreeView32 If enabled, specifies that the object's class (that is, XTPToolBar, SysTreeView, MDIClient) will be examined when determining a matching object. If disabled, the class will be ignored.
FrameworkId Text No (Empty) FRAMEWORKID=WPF If enabled, specifies that the object's framework ID (the framework technology used to create the object) will be examined when determining a matching object. If disabled, the framework ID will be ignored.
Name Text No (Empty) NAME=Cancel If enabled, specifies that the object's name (a unique identifier for an object) will be examined when determining a matching object. If disabled, the name will be ignored.
AutomationId Text No (Empty) AUTOMATIONID=System If enabled, specifies that the object's automation ID (a unique identifier for an object) will be examined when determining a matching object. If disabled, the automation ID will be ignored.
Value Text No (Empty) VALUE=1 If enabled, specifies that the object's value (which usually coincides with the Name property) will be examined when determining a matching object. If disabled, the value will be ignored.
Role Text No (Empty) ROLE=desktop pane If enabled, specifies that the object's role type (the control type provided by the Java Accessibility bridge) will be examined when determining a matching object. If disabled, the role type will be ignored.
Description Text No (Empty) DESCRIPTION=JScrollPane If enabled, specifies that the object's description (the description given for an object) will be examined when determining a matching object. If disabled, the description will be ignored.
X Number No (Empty) X=80 If enabled, specifies that the object's X coordinate (a given number of pixels along the horizontal axis of a window starting from the extreme left side) will be examined when determining a matching object. If disabled, the X coordinate will be ignored.
NOTE: The X and Y coordinates are relative to the specified window as opposed to the screen.
Y Number No (Empty) Y=90 If enabled, specifies that the object's Y coordinate (a given number of pixels along the vertical axis of a window starting from the top-most portion) will be examined when determining a matching object. If disabled, the Y coordinates will be ignored.
NOTE: The X and Y coordinates are relative to the specified window as opposed to the screen.
Width Number No (Empty) WIDTH=711 If enabled, specifies that the object's pixel width will be examined when determining a matching object. If disabled, the pixel width will be ignored.
Height Number No (Empty) HEIGHT=42 If enabled, specifies that the object's pixel height will be examined when determining a matching object. If disabled, the pixel height will be ignored.
IndexInParent Text No (Empty) INDEXINPARENT=1 If enabled, specifies that the object's index in parent number (the numeric identifier of a child object located within a parent object) will be examined when determining a matching object. If disabled, the index in parent number will be ignored.
ParentPath Text No (Empty) PARENTPATH=50032|50033 If enabled, specifies that the object's parent path (the sequence of control type identifiers that lead to the object) will be examined when determining a matching object. If disabled, the parent path will be ignored.
Occurrence Number No (Empty) OCCURRENCE=1 If enabled, specifies that the object's occurrence (the numeric identifier of an object, useful when multiple matching objects are found) will be examined when determining a matching object. If disabled, the occurrence will be ignored.

Behavior

 
PropertyData TypeDescription
Enable TriggerYes/NoIf selected, the trigger will immediately be active upon creation. If disabled, the trigger will stay inactive until it is manually enabled. This parameter is selected by default.
Trigger on startup if condition is trueYes/NoIf enabled, the system will act upon conditions that already exist upon startup of the current trigger. For example, if the Notepad window is already open on the desktop, a newly created Window trigger set to monitor for the existence of a Notepad window will immediately launch the task as a result. If disabled, the trigger will ignore the open Notepad window upon startup. This parameter is disabled by default.
Trigger after the condition has been met 'X' times.Yes/NoIf enabled, specifies how many times the trigger condition must be met before the task is started. For example, if a Window trigger is set to monitor for the appearance of a Notepad window and this parameter is set to 3, the task will not launch until the third instance of Notepad appears on the desktop.

Additional Notes

AMTrigger

When this trigger is activated, it automatically passes the AMTrigger object to the task. AMTrigger is a standard Automate dataset and can be used much like the datasets created by the Database - SQL query activity and Email action. The fields of AMTrigger can be used within a task to determine specific values, such as whether or not the task was started by a trigger, which trigger started the task, when the trigger was activated and other properties. AMTrigger populates a unique set of field–value pairs for each Automate trigger. The following table lists the ones specific to this trigger. For more details about a specific AMTrigger field–value pair, click the associated link.

NameData TypeReturn Value
AMTrigger.ActionStringReturns the action that took place to cause the task to trigger.
AMTrigger.WindowClassNumberReturns the unique window class of the window that activated the trigger.
AMTrigger.WindowHandleStringReturns the handle of the window that activated the trigger.
AMTrigger.WindowTitleStringReturns the title of the window that activated the trigger.

NOTE: A full list of AMTrigger objects exclusive to each trigger can be viewed from the Expression Builder by expanding Objects > Triggers and then selecting the desired trigger.