IUIAutomation::AddAutomationEventHandler Method

Registers a method that handles Microsoft UI Automation events.

Syntax

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

Parameters

  • eventId
    [in] The identifier of the event that the method handles. For a list of event IDs, see Event Identifiers.
  • element
    [in] The address of the IUIAutomationElement interface of the UI Automation element to associate with the event handler.
  • scope
    [in] A value from the TreeScope enumerated type specifying the scope of events to be handled; that is, whether they are on the element itself, or on its ancestors and descendants.
  • cacheRequest
    [in] The address of the IUIAutomationCacheRequest interface of a cache request, or NULL if no caching is wanted.
  • handler
    [in] The address of the IUIAutomationEventHandler interface of the object that handles the event.

Return Value

Returns S_OK if successful, or an error value otherwise.

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.

See Also

IUIAutomationEventHandler, IUIAutomation::RemoveAutomationEventHandler, IUIAutomation::RemoveAllEventHandlers, Caching UI Automation Properties and Control Patterns, UI Automation Events for Clients