语言

AutomationEvent 类

定义

标识UI 自动化事件。

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 参数与标识 Invoked 事件进行比较 AutomationEvent 。

/// <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

注解

这些类型的标识符作为各种类中的字段来标识事件;例如, InvokedEvent. 在传递给UI 自动化客户端的事件参数中也发现了它们。

无法创建自定义事件。

属性

名称 说明
Id

获取基础数字标识符。

(继承自 AutomationIdentifier)
ProgrammaticName

获取已注册的编程名称。

(继承自 AutomationIdentifier)

方法

名称 说明
CompareTo(Object)

将此 AutomationIdentifier 与另一个 AutomationIdentifier进行比较。

(继承自 AutomationIdentifier)
Equals(Object)

返回一个值,该值指示提供的 AutomationIdentifier 是否等效于此 AutomationIdentifier值。

(继承自 AutomationIdentifier)
GetHashCode()

返回此UI 自动化标识符的哈希代码。

(继承自 AutomationIdentifier)
GetType()

获取当前实例的 Type。

(继承自 Object)
LookupById(Int32)

检索封装指定数字标识符的一个 AutomationEvent 。

MemberwiseClone()

创建当前 Object的浅表副本。

(继承自 Object)
ToString()

返回一个表示当前对象的字符串。

(继承自 Object)

适用于

另请参阅