IUIAutomation::AddAutomationEventHandler method

Registers a method that handles Microsoft UI Automation events.

Note  Before implementing an event handler, you should be familiar with the threading issues described in Understanding Threading Issues.
 

Syntax

HRESULT AddAutomationEventHandler(
  EVENTID                   eventId,
  IUIAutomationElement      *element,
  TreeScope scope           ,
  IUIAutomationCacheRequest *cacheRequest,
  IUIAutomationEventHandler *handler
);

Parameters

eventId

Type: EVENTID

The identifier of the event that the method handles. For a list of event IDs, see Event Identifiers.

element

Type: IUIAutomationElement*

A pointer to the UI Automation element to associate with the event handler.

arg3

Type: TreeScope

The scope of events to be handled; that is, whether they are on the element itself, or on its ancestors and descendants.

cacheRequest

Type: IUIAutomationCacheRequest*

A pointer to a cache request, or NULL if no caching is wanted.

handler

Type: IUIAutomationEventHandler*

A pointer to the object that handles the event.

Return Value

Type: HRESULT

If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.

Remarks

A UI Automation client should not use multiple threads to add or remove event handlers. Unexpected behavior can result if one event handler is being added or removed while another is being added or removed in the same client process.

Requirements

   
Minimum supported client Windows 7, Windows Vista with SP2 and Platform Update for Windows Vista, Windows XP with SP3 and Platform Update for Windows Vista [desktop apps only]
Minimum supported server Windows Server 2008 R2, Windows Server 2008 with SP2 and Platform Update for Windows Server 2008, Windows Server 2003 with SP2 and Platform Update for Windows Server 2008 [desktop apps only]
Target Platform Windows
Header uiautomationclient.h (include UIAutomation.h)

See Also

Caching UI Automation Properties and Control Patterns

Conceptual

IUIAutomation

IUIAutomationEventHandler

Reference

RemoveAllEventHandlers

RemoveAutomationEventHandler

Subscribing to UI Automation Events

Understanding Threading Issues