IUIAutomation::AddAutomationEventHandler 方法 (uiautomationclient.h)

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

注意 實作事件處理程式之前,您應該熟悉 瞭解線程問題中所述的線程問題。
 

語法

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

參數

[in] eventId

類型:EVENTID

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

[in] element

類型:IUIAutomationElement*

要與事件處理程式產生關聯的UI Automation元素指標。

[in] scope

類型:TreeScope

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

[in] cacheRequest

類型:IUIAutomationCacheRequest*

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

[in] handler

類型:IUIAutomationEventHandler*

處理事件之 物件的指標。

傳回值

類型:HRESULT

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

言論

使用者介面自動化客戶端不應該使用多個線程來新增或移除事件處理程式。 如果在相同客戶端進程中新增或移除另一個事件處理程式,則非預期的行為可能會導致。

要求

要求 價值
最低支援的用戶端 Windows 7、Windows Vista SP2 和 Platform Update for Windows Vista、Windows XP with SP3 和 Platform Update for Windows Vista [僅限傳統型應用程式]
支援的最低伺服器 Windows Server 2008 R2、Windows Server 2008 SP2 和 Platform Update for Windows Server 2008、Windows Server 2003 SP2 和 Platform Update for Windows Server 2008 [僅限傳統型應用程式]
目標平臺 窗戶
標頭 uiautomationclient.h (include UIAutomation.h)

另請參閱

快取UI自動化屬性和控制項模式

概念

IUIAutomation

IUIAutomationEventHandler

參考

RemoveAllEventHandlers

RemoveAutomationEventHandler

訂閱使用者介面自動化事件

了解線程問題