AutomationEvent AutomationEvent AutomationEvent AutomationEvent Class

Definition

Identifies a UI Automation event.

public ref class AutomationEvent : System::Windows::Automation::AutomationIdentifier
public class AutomationEvent : System.Windows.Automation.AutomationIdentifier
type AutomationEvent = class
    inherit AutomationIdentifier
Public Class AutomationEvent
Inherits AutomationIdentifier
Inheritance

Examples

In the following example event handler, the AutomationEvent in the event arguments is compared with the AutomationEvent that identifies the Invoked event.

/// <summary>
/// AutomationEventHandler delegate.
/// </summary>
/// <param name="src">Object that raised the event.</param>
/// <param name="e">Event arguments.</param>
private void OnUIAutomationEvent(object src, AutomationEventArgs e)
{
    // Make sure the element still exists. Elements such as tooltips
    // can disappear before the event is processed.
    AutomationElement sourceElement;
    try
    {
        sourceElement = src as AutomationElement;
    }
    catch (ElementNotAvailableException)
    {
        return;
    }
    if (e.EventId == InvokePattern.InvokedEvent)
    {
        // TODO Add handling code.
    }
    else
    {
        // TODO Handle any other events that have been subscribed to.
    }
}
''' <summary>
''' AutomationEventHandler delegate.
''' </summary>
''' <param name="src">Object that raised the event.</param>
''' <param name="e">Event arguments.</param>
Private Sub OnUIAutomationEvent(ByVal src As Object, ByVal e As AutomationEventArgs)
    ' Make sure the element still exists. Elements such as tooltips can disappear
    ' before the event is processed.
    Dim sourceElement As AutomationElement
    Try
        sourceElement = DirectCast(src, AutomationElement)
    Catch ex As ElementNotAvailableException
        Exit Sub
    End Try
    If e.EventId Is InvokePattern.InvokedEvent Then
        ' TODO Add handling code.
    Else
    End If
    ' TODO Handle any other events that have been subscribed to.
    Console.WriteLine("Event: " & e.EventId.ProgrammaticName)
End Sub 'OnUIAutomationEvent

Remarks

Identifiers of these types are found as fields in various classes to identify events; for example, InvokedEvent. They are also found in the event arguments passed to UI Automation clients.

It is not possible to create custom events.

Methods

CompareTo(Object) CompareTo(Object) CompareTo(Object) CompareTo(Object)

Compares this AutomationIdentifier with another AutomationIdentifier.

(Inherited from AutomationIdentifier)
Equals(Object) Equals(Object) Equals(Object) Equals(Object)

Returns a value indicating whether the supplied AutomationIdentifier is equivalent to this AutomationIdentifier.

(Inherited from AutomationIdentifier)
GetHashCode() GetHashCode() GetHashCode() GetHashCode()

Returns the hash code for this UI Automation identifier.

(Inherited from AutomationIdentifier)
GetType() GetType() GetType() GetType()

Gets the Type of the current instance.

(Inherited from Object)
LookupById(Int32) LookupById(Int32) LookupById(Int32) LookupById(Int32)

Retrieves an AutomationEvent that encapsulates the specified numerical identifier.

MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

Creates a shallow copy of the current Object.

(Inherited from Object)
ToString() ToString() ToString() ToString()

Returns a string that represents the current object.

(Inherited from Object)

Properties

Id Id Id Id

Gets the underlying numerical identifier.

(Inherited from AutomationIdentifier)
ProgrammaticName ProgrammaticName ProgrammaticName ProgrammaticName

Gets the registered programmatic name.

(Inherited from AutomationIdentifier)

Applies to

See also