共用方式為


IUIAutomationEventHandlerGroup::AddAutomationEventHandler 方法 (uiautomationclient.h)

註冊處理MICROSOFT用戶介面自動化事件的方法。

重要 UI 自動化用戶端應該使用處理程式群組方法來註冊事件接聽程式,而不是在各種 IUIAutomation 命名空間中定義的個別事件註冊方法。
 

語法

HRESULT AddAutomationEventHandler(
  [in] EVENTID                   eventId,
  [in] TreeScope                 scope,
  [in] IUIAutomationCacheRequest *cacheRequest,
  [in] IUIAutomationEventHandler *handler
);

參數

[in] eventId

方法所處理之事件的標識碼。 如需事件標識碼的清單,請參閱事件標識符。

[in] scope

要處理的事件範圍;也就是說,無論是在元素本身上,還是在其祖先和子代上。

[in] cacheRequest

快取要求的指標,如果不需要任何快取,則 NULL

[in] handler

處理事件之 物件的指標。

傳回值

如果此方法成功,則會傳回 S_OK。 否則,它會傳回 HRESULT 錯誤碼。

要求

要求 價值
最低支援的用戶端 Windows 10 版本 1809 [僅限傳統型應用程式]
支援的最低伺服器 Windows Server 版本 1709 [僅限傳統型應用程式]
目標平臺 窗戶
標頭 uiautomationclient.h (include UIAutomation.h)

另請參閱

IUIAutomationEventHandlerGroup