AutomationEvent 类

定义

标识 UI 自动化事件。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
继承
AutomationEvent

示例

在下面的示例事件处理程序中AutomationEvent , 事件参数中的与用于标识AutomationEvent调用事件的进行比较。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

注解

这些类型的标识符在各种类中作为字段来标识事件;例如, InvokedEventIdentifiers of these types are found as fields in various classes to identify events; for example, InvokedEvent. 它们还可以在传递给 UI 自动化客户端的事件参数中找到。They are also found in the event arguments passed to UI Automation clients.

不能创建自定义事件。It is not possible to create custom events.

属性

Id

获取基础数值标识符。Gets the underlying numerical identifier.

(继承自 AutomationIdentifier)
ProgrammaticName

获取注册的编程名称。Gets the registered programmatic name.

(继承自 AutomationIdentifier)

方法

CompareTo(Object)

将此 AutomationIdentifier 与其他 AutomationIdentifier 相比较。Compares this AutomationIdentifier with another AutomationIdentifier.

(继承自 AutomationIdentifier)
Equals(Object)

返回一个值,该值指示提供的 AutomationIdentifier 是否等效于此 AutomationIdentifierReturns a value indicating whether the supplied AutomationIdentifier is equivalent to this AutomationIdentifier.

(继承自 AutomationIdentifier)
GetHashCode()

返回此 UI 自动化UI Automation标识符的哈希代码。Returns the hash code for this UI 自动化UI Automation identifier.

(继承自 AutomationIdentifier)
GetType()

获取当前实例的 TypeGets the Type of the current instance.

(继承自 Object)
LookupById(Int32)

检索封装指定的数值标识符的 AutomationEventRetrieves an AutomationEvent that encapsulates the specified numerical identifier.

MemberwiseClone()

创建当前 Object 的浅表副本。Creates a shallow copy of the current Object.

(继承自 Object)
ToString()

返回表示当前对象的字符串。Returns a string that represents the current object.

(继承自 Object)

适用于

另请参阅