Triggers: accessible object

Launches the macro when the specified accessible object generates an event. To assign this trigger, use the Properties dialog.


Accessible objects are various user interface objects in a window, such as buttons, text fields, list items, links, menus. This trigger type also supports objects that are not window parts: top-level windows, caret (text cursor), cursor (mouse pointer), sound and alert. There are numerous events that can be used to launch the macro. Examples:


When an object is created or destroyed.

When an object receives focus.

When an object's state or location changes.

When any of an object's properties change.


To discover events and object properties, use accessible object event logging. Right click the output pane and check Log -> Acc. events in the menu. In the logging options dialog you can specify certain filters, to exclude some types of events and objects.


For each event, in the output is displayed indexed string that has this format:

i. event, idObject, idChild

    ow: object window class, id and text

    pw: top-level parent window class and name

    ao: accessible object properties


Properties that cannot be retrieved are not displayed. For example, if the object window is top-level window, it does not have parent window, and pw line is not displayed. In the Properties dialog, leave corresponding fields empty.


In the Properties dialog, select an event in the list at left, and enter other properties in the right. All properties except idObject are optional, but should be specified at least object window class (or/and id) and parent window class (and name, if class isn't unique). Accessible object properties and child window text are slower to retrieve, and therefore should be used only if really necessary. Note that idChild is not child window id, but is used to identify the accessible object. If it is some nonzero value, consider checking "Any nonzero", because often it is nonconstant.


Class names must be full or with wildcard characters (QM 2.3.4). Other strings can be partial. If Use * is checked, must be full or with wildcard characters. Empty fields are not evaluated. To match empty string, use single * character in that field.


There are quite many fields in the Properties dialog. It is easy to make a mistake when filling them. If the trigger does not work (macro does not run) when expected, temporarily check Debug and click OK. Then try to reproduce the conditions that should cause the macro to run. In the output pane will be displayed the first property that doesnt match when an event of that type occurs and these properties match: idObject, idChild, ow class and pw class.


The macro can receive trigger information through the function statement that is inserted with your confirmation when you close the Properties dialog. hwnd is object window handle. If it is a child window, you can use int h=GetAncestor(hwnd 2) to get its top-level parent window handle. To get the accessible object, you can use ObjectFromEvent function of Acc class.


Before logging, save all your work in all programs, because some events of some objects may crash the program to which the object belongs. When an exception occurs while logging, QM tries to handle it so that the program would not crash, but it is not always possible. Particularly, exceptions occur when QM tries to get accessible object properties. This is another reason why you should not use accessible object properties in triggers where the object can be identified not using them. To make logging safe, check "don't get ao properties".


Events "destroy" and "hide" are unreliable with 64-bit windows.


This trigger type is based on Microsoft Active Accessibility and WinEvents. You can read more in MSDN library (search for WinEvents). To read about event types, search MSDN for "Event Constants".



Let's make trigger "any web page in Internet Explorer is opened and fully loaded". Open Internet Explorer (IE). Then switch to QM, right click the output pane and select Log -> Acc. events in the popup menu. In the dialog, click OK. Switch to IE and open a page, for example, Google page. Then switch to QM and stop logging (click the same menu item). Try to find an event that could be used for this trigger. Probably the best event is this (or similar; may depend on Internet Explorer version):



ow: class="Internet Explorer_Server", id=0

pw: class="IEFrame", name="Google - Microsoft Internet Explorer"

ao: role=PANE, state=0x100040, name="Google", value=""


Open the Properties dialog, select Accessible object, CREATE. In the right, enter object window class (Internet Explorer_Server) and top-level parent window class (IEFrame). As parent window name, optionally enter Internet Explorer. Click Next and select PANE in the Role combobox. Leave Name and Value fields empty, unless you want to make the trigger specific to this page only.


Click OK. QM will ask whether to insert code to receive trigger properties. Let's say, you need page URL. Then click Yes. It adds two lines of code at the beginning of the macro. Uncomment the second line (delete space at the beginning). The a variable can be used to access and manipulate the PANE accessible object. Its Value property contains the URL of the page. Insert the code to get the Value property. You can use the Accessible Object Actions dialog to insert it.


function hwnd idObject idChild
Acc a.ObjectFromEvent(hwnd idObject idChild)
str value=a.Value
out value