Share via


IRawElementProviderAdviseEvents.AdviseEventAdded(Int32, Int32[]) 方法

定義

使用者介面自動化用戶端開始接聽特定事件 (包括屬性變更的事件) 時,通知使用者介面自動化提供者。

public:
 void AdviseEventAdded(int eventId, cli::array <int> ^ properties);
public void AdviseEventAdded (int eventId, int[] properties);
abstract member AdviseEventAdded : int * int[] -> unit
Public Sub AdviseEventAdded (eventId As Integer, properties As Integer())

參數

eventId
Int32

要加入之事件的識別項。

properties
Int32[]

要加入之屬性的識別項,或者,如果要加入的事件接聽程式目前未接聽屬性事件,則為 null

範例

下列範例會將 新增至已訂閱的屬性變更清單。

void IRawElementProviderAdviseEvents.AdviseEventAdded(int eventId, 
                                                      int[] properties)
{
    if (eventId == AutomationElement.AutomationPropertyChangedEvent.Id)
    {
        foreach (int i in properties)
        {
            AutomationProperty property = AutomationProperty.LookupById(i);
            // Add to an ArrayList.
            subscribedProperties.Add(property);
        }
    }
}
Sub AdviseEventAdded(ByVal eventId As Integer, ByVal properties() As Integer) _
    Implements IRawElementProviderAdviseEvents.AdviseEventAdded

    If eventId = AutomationElement.AutomationPropertyChangedEvent.Id Then
        For Each i As Integer In properties
            Dim autoProperty As AutomationProperty = AutomationProperty.LookupById(i)
            ' Add to an ArrayList.
            subscribedProperties.Add(autoProperty)
        Next
    End If

End Sub

備註

這個方法可讓提供者藉由只引發正在接聽的事件來降低額外負荷。

eventId可以與 Id 這類 WindowClosedEventAutomationEvent 比較。 您也可以使用 LookupById 取得 AutomationEvent

適用於