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 dialogs can be automatically handled when they appear. For example, a notification message can be sent to the system administrator upon the occurrence of an error.

Related Topics  

Parameters

General

This trigger comprises Automate Desktop's Window Dissection technology to facilitate the discovery of existing windows and their controls.

To select the target window:

  1. Ensure 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 appears around it.
  3. Upon releasing the icon, identified window properties are populated onto the editor. These properties can be enabled, disabled or modified.
Property Type Description
Trigger if/when Options Specifies the window state to monitor. The available options are:
  • Window open (default) - The trigger fires when the specified window opens.
  • Window closed- The trigger fires when the specified window closes.
  • Window focused - The trigger fires when the specified window becomes focused (brought to the foreground).
  • Window not focused - The trigger fires 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 occurs 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 occurs 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 closes 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 is 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* includes 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* includes 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 might be necessary to use Automate Desktop 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 click Add to open the Object Editor dialog.

To specify additional elements:

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

The following are available object properties:

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 type (that is, Button, Checkbox, Trackbar) is examined when determining a matching object. If disabled, the type is ignored.
Class Text No (Empty) CLASS=SysTreeView32 If enabled, specifies that the object class (that is, XTPToolBar, SysTreeView, MDIClient) is examined when determining a matching object. If disabled, the class is ignored.
FrameworkId Text No (Empty) FRAMEWORKID=WPF If enabled, specifies that the object framework ID (the framework technology used to create the object) is examined when determining a matching object. If disabled, the framework ID is ignored.
Name Text No (Empty) NAME=Cancel If enabled, specifies that the object name (a unique identifier for an object) is examined when determining a matching object. If disabled, the name is ignored.
AutomationId Text No (Empty) AUTOMATIONID=System If enabled, specifies that the object automation ID (a unique identifier for an object) is examined when determining a matching object. If disabled, the automation ID is ignored.
Value Text No (Empty) VALUE=1 If enabled, specifies that the object value (which usually coincides with the Name property) is examined when determining a matching object. If disabled, the value is ignored.
Role Text No (Empty) ROLE=desktop pane If enabled, specifies that the object role type (the control type provided by the Java Accessibility bridge) is examined when determining a matching object. If disabled, the role type is ignored.
Description Text No (Empty) DESCRIPTION=JScrollPane If enabled, specifies that the object description (the description given for an object) is examined when determining a matching object. If disabled, the description is ignored.
X Number No (Empty) X=80 If enabled, specifies that the object X coordinate (a given number of pixels along the horizontal axis of a window starting from the extreme left side) is examined when determining a matching object. If disabled, the X coordinate is 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 Y coordinate (a given number of pixels along the vertical axis of a window starting from the top-most portion) is examined when determining a matching object. If disabled, the Y coordinates is 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 pixel width is examined when determining a matching object. If disabled, the pixel width is ignored.
Height Number No (Empty) HEIGHT=42 If enabled, specifies that the object pixel height is examined when determining a matching object. If disabled, the pixel height is ignored.
IndexInParent Text No (Empty) INDEXINPARENT=1 If enabled, specifies that the object index in parent number (the numeric identifier of a child object located within a parent object) is examined when determining a matching object. If disabled, the index in parent number is ignored.
ParentPath Text No (Empty) PARENTPATH=50032|50033 If enabled, specifies that the object parent path (the sequence of control type identifiers that lead to the object) is examined when determining a matching object. If disabled, the parent path is ignored.
Occurrence Number No (Empty) OCCURRENCE=1 If enabled, specifies that the object occurrence (the numeric identifier of an object, useful when multiple matching objects are found) is examined when determining a matching object. If disabled, the occurrence is ignored.

Advanced

Property Data Type Description
Delay to wait for before analyzing a window Number Specifies a delay, in milliseconds (default is 1000), to prevent the window trigger from immediately checking window contents.

Behavior

 
PropertyData TypeDescription
Enable TriggerYes/NoIf selected, the trigger is immediately active upon creation. If disabled, the trigger remains inactive until it is manually enabled. This parameter is selected by default.
Trigger on startup if condition is trueYes/NoIf enabled, the system acts 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 immediately launches the task as a result. If disabled, the trigger ignores 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 starts. 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 does 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 Desktop 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 is started by a trigger, which trigger started the task, when the trigger is activated and other properties. AMTrigger populates a unique set of field–value pairs for each Automate Desktop 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.