AutomationEvent Class
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
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
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.
Properties
Id |
Gets the underlying numerical identifier. (Inherited from AutomationIdentifier) |
ProgrammaticName |
Gets the registered programmatic name. (Inherited from AutomationIdentifier) |
Methods
CompareTo(Object) |
Compares this AutomationIdentifier with another AutomationIdentifier. (Inherited from AutomationIdentifier) |
Equals(Object) |
Returns a value indicating whether the supplied AutomationIdentifier is equivalent to this AutomationIdentifier. (Inherited from AutomationIdentifier) |
GetHashCode() |
Returns the hash code for this UI Automation identifier. (Inherited from AutomationIdentifier) |
GetType() |
Gets the Type of the current instance. (Inherited from Object) |
LookupById(Int32) |
Retrieves an AutomationEvent that encapsulates the specified numerical identifier. |
MemberwiseClone() |
Creates a shallow copy of the current Object. (Inherited from Object) |
ToString() |
Returns a string that represents the current object. (Inherited from Object) |