Jump to content
LarsJ

UI Automation Events

Recommended Posts

UIA Menu, Tooltip and Window Events Monitor
UIA Menu, Tooltip and Window Events Monitor is a simpler version of UI Automation Event Monitor (first post) that detects only MenuOpened, ToolTipOpened and Window_WindowOpened events (AutomationEvents):

EZcyqbQ.png

Click Start to begin event detection.

A single CheckboxCombo control is used to choose between Menu, Tooltip and Window Opened events.

The buttons work the same way as described for the GUI in first post.

The listview shows the events generated when Google Chrome is opened, when the mouse hovers over the Customize button (the three vertical dots in upper right corner) so that a Tooltip is displayed, and when the Customize button is clicked so that the Customize menu pops up.

For Tooltips and Windows, the first level child controls are also displayed in the listview. For Menus, all child controls are displayed.

A right-click context menu is added to the listview. It's only applicable if the listview update is Paused or Stopped. The context menu provides access to copy selected or all items to clipboard. (The context menu will be added to the listview in first post in a later update.) The clipboard gets this content when all items in the listview above are copied:

1    Window_WindowOpened    Pane: about:blank - Google Chrome, 0x0001034E
                                Document: Chrome_RenderWidgetHostHWND, 0x00010352
                                TitleBar
                                Pane: Google Chrome
2    ToolTipOpened          ToolTip: Customize and control Google Chrome, 0x00040242
3    MenuOpened             Pane: Chrome_WidgetWin_2, 0x00010360
                                MenuBar
                                    Pane
                                        Menu
                                            MenuItem: New tab Ctrl+T
                                            MenuItem: New window Ctrl+N
                                            MenuItem: New incognito window Ctrl+Shift+N
                                            Pane
                                            MenuItem: History
                                            MenuItem: Downloads Ctrl+J
                                            MenuItem: Bookmarks
                                            Pane
                                            MenuItem: Zoom
                                                Menu
                                                    MenuItem: Make Text Smaller
                                                    Custom: 100%
                                                    MenuItem: Make Text Larger
                                                    MenuItem: Full screen F11
                                            Pane
                                            MenuItem: Print… Ctrl+P
                                            MenuItem: Cast…
                                            MenuItem: Find… Ctrl+F
                                            MenuItem: More tools
                                            Pane
                                            MenuItem: Edit
                                                Menu
                                                    MenuItem: Cut Ctrl+X
                                                    MenuItem: Copy Ctrl+C
                                                    MenuItem: Paste Ctrl+V
                                            Pane
                                            MenuItem: Settings
                                            MenuItem: Help
                                            Pane
                                            MenuItem: Exit


The reason I've made a separate GUI for these three events is that they are very useful events, but especially because I plan to add detection of these events in UIASpy. In UIASpy, it can be difficult to get information about menus, tooltips and popup and flyout windows (Windows 10 uses a whole lot of these windows) with the mouse and the F1 - F4 keys. But before I add the functionality to UIASpy, I want to make sure it works. Therefore, this GUI.

You need AutoIt 3.3.12 or later. Tested on Windows 7 and Windows 10. The code should run on all Windows versions.

Comments are welcome. Let me know if there are any issues.

New zip-file at bottom of first post.

Edited by LarsJ

Share this post


Link to post
Share on other sites

Notepad context menu
Automating a context menu consists of opening the menu, detecting the open menu and clicking a menu item. Here, the technique is demonstrated with Notepad as an example and the "Right to left Reading order" menu item in the context menu of the Edit control. The inspiration for the example is found in this thread.

Opening the menu
A small two-button GUI is used to open the context menu by generating a secondary mouse click:

; Create AutoIt GUI
Local $hGui = GUICreate( "Automate Notepad Context Menu", 330, 40, 100, 100 )
Local $idRight = GUICtrlCreateButton( "Right to left Reading order",  10, 10, 150, 20 )
Local $idLeft  = GUICtrlCreateButton( "Left to right Reading order", 170, 10, 150, 20 )
GUICtrlSetState( $idLeft, $GUI_DISABLE )

; Show GUI
GUISetState( @SW_SHOW )

; Main loop
Local $iMsg
While 1
  $iMsg = GUIGetMsg()
  Switch $iMsg
    Case $idRight, $idLeft
      ; Secondary mouse click
      UIA_WinActivate( $oNotepad )
      UIA_WinWaitActive( $oNotepad )
      UIA_MouseClick( $oEdit1, True )
      GUICtrlSetState( $iMsg = $idRight ? $idRight : $idLeft, $GUI_DISABLE )
      GUICtrlSetState( $iMsg = $idRight ? $idLeft : $idRight, $GUI_ENABLE )
      ConsoleWrite( @CRLF & "Secondary mouse click" & @CRLF )


Detecting the open menu
The event handler to detect menu open events is created this way:

; Create UI Automation event handler
UIAEH_AutomationEventHandlerCreate()
If Not IsObj( $oUIAEH_AutomationEventHandler ) Then Return ConsoleWrite( "$oUIAEH_AutomationEventHandler ERR" & @CRLF )
ConsoleWrite( "$oUIAEH_AutomationEventHandler OK" & @CRLF )

; Detect menu open events
Local $iError = $oUIAutomation.AddAutomationEventHandler( $UIA_MenuOpenedEventId, $pDesktop, $TreeScope_Subtree, 0, $oUIAEH_AutomationEventHandler )
If $iError Then Return ConsoleWrite( "AddAutomationEventHandler() ERR" & @CRLF )
ConsoleWrite( "AddAutomationEventHandler() OK" & @CRLF )

This is the function that receives events. The event is sent to the AutoIt main loop using a dummy control, $idContextMenu:

; This is the function that receives events
Func UIAEH_AutomationEventHandler_HandleAutomationEvent( $pSelf, $pSender, $iEventId ) ; Ret: long  Par: ptr;int
  ConsoleWrite( "UIAEH_AutomationEventHandler_HandleAutomationEvent: $iEventId = " & $iEventId & @CRLF )
  $oContextMenu = ObjCreateInterface( $pSender, $sIID_IUIAutomationElement, $dtag_IUIAutomationElement )
  $oContextMenu.AddRef()
  If Not IsObj( $oContextMenu ) Then Return ConsoleWrite( "$oContextMenu ERR" & @CRLF )
  ConsoleWrite( "$oContextMenu OK" & @CRLF )
  GUICtrlSendToDummy( $idContextMenu )
  Return 0x00000000 ; $S_OK
  #forceref $pSelf
EndFunc


Clicking a menu item
And this is code that clicks the "Right to left Reading order" menu item:

Case $idContextMenu
  ; Context menu item
  Local $pAndCondition1
  $oUIAutomation.CreatePropertyCondition( $UIA_ControlTypePropertyId, $UIA_MenuItemControlTypeId, $pCondition0 )
  $oUIAutomation.CreatePropertyCondition( $UIA_NamePropertyId, "Right to left Reading order", $pCondition1 )
  $oUIAutomation.CreateAndCondition( $pCondition0, $pCondition1, $pAndCondition1 )
  If Not $pAndCondition1 Then Return ConsoleWrite( "$pAndCondition1 ERR" & @CRLF )
  ConsoleWrite( "$pAndCondition1 OK" & @CRLF )

  ; Find Context menu item
  Local $pMenuItem1, $oMenuItem1
  $oContextMenu.FindFirst( $TreeScope_Descendants, $pAndCondition1, $pMenuItem1 )
  $oMenuItem1 = ObjCreateInterface( $pMenuItem1, $sIID_IUIAutomationElement, $dtag_IUIAutomationElement )
  If Not IsObj( $oMenuItem1 ) Then Return ConsoleWrite( "$oMenuItem1 ERR" & @CRLF )
  ConsoleWrite( "$oMenuItem1 OK" & @CRLF )

  ; Click Context menu item
  Local $pInvokePattern1, $oInvokePattern1
  $oMenuItem1.GetCurrentPattern( $UIA_InvokePatternId, $pInvokePattern1 )
  $oInvokePattern1 = ObjCreateInterface( $pInvokePattern1, $sIID_IUIAutomationInvokePattern, $dtag_IUIAutomationInvokePattern )
  If Not IsObj( $oInvokePattern1 ) Then Return ConsoleWrite( "$oInvokePattern1 ERR" & @CRLF )
  ConsoleWrite( "$oInvokePattern1 OK" & @CRLF )
  $oInvokePattern1.Invoke()
  ConsoleWrite( "$oInvokePattern1.Invoke()" & @CRLF )


Full code in Examples\Notepad context menu\ContextMenu.au3. Note that because of the UIAEH_AutomationEventHandler.au3 UDF, the code in the example here is much simpler than the code in the link above.

To run the example open Notepad and enter or paste some text into the Edit control. Then run ContextMenu.au3 in SciTE with F5.

New zip-file at bottom of first post.

Share this post


Link to post
Share on other sites

Windows 8, Windows 8.1 and Windows 10 updates
In Windows 8 and later, new event handlers have been added and new events and property changes have been added to existing event handlers. This is an update to be able to take advantage of these new event handlers, events and property changes.

Four new event handlers have been added:

IUIAutomationTextEditTextChangedEventHandler       ; Windows 8.1
IUIAutomationChangesEventHandler                   ; Windows 10-1703
IUIAutomationNotificationEventHandler              ; Windows 10-1709
IUIAutomationActiveTextPositionChangedEventHandler ; Windows 10-1809

The corresponding four new EventIds that can be used in the existing AutomationEventHandler are:

Global Const $UIA_TextEdit_TextChangedEventId      = 20032 ; Windows 8.1
Global Const $UIA_ChangesEventId                   = 20034 ; Windows 10
Global Const $UIA_NotificationEventId              = 20035 ; Windows 10
Global Const $UIA_ActiveTextPositionChangedEventId = 20036 ; Windows 10

In addition to the listed EventIds, there are 10 more EventIds that can be used in the existing AutomationEventHandler. And there are more than 60 new PropertyIds that can be used in the existing PropertyChangedEventHandler.

By detecting events for the four new EventIds listed above in UI Automation Event Monitor (UIAEHEvents.au3, see description of updates below) I've tried to find applications that actually generates some of these new events. I've found that the Windows 10 Calculator and Microsoft Edge browser generates Notification events. With the new NotificationEventHandler it's possible to obtain further information about these events.

I've not found any applications that generates the other three events. And thus I've not found any applications where it's possible to test the new TextEditTextChangedEventHandler, ChangesEventHandler and ActiveTextPositionChangedEventHandler.

Therefore, the only new event handler implemented in this update is the NotificationEventHandler.
 

NotificationEventHandler
NotificationEventHandler
exposes a method to handle Microsoft UI Automation notification events.

The UDF is implemented in Includes\UIAEH_NotificationEventHandler.au3:

#include-once
#include "UIA_Constants.au3"
#include "UIA_ConstNames.au3"
#include "UIA_Functions.au3"
#include "ObjectFromTag.au3"

NotificationKindSetNames()
NotificationProcessingSetNames()

Global $oUIAEH_NotificationEventHandler, $tUIAEH_NotificationEventHandler

Func UIAEH_NotificationEventHandlerCreate()
  $oUIAEH_NotificationEventHandler = ObjectFromTag( "UIAEH_NotificationEventHandler_", $dtag_IUIAutomationNotificationEventHandler, $tUIAEH_NotificationEventHandler, True )
EndFunc

Func UIAEH_NotificationEventHandlerDelete()
  $oUIAEH_NotificationEventHandler = 0
  DeleteObjectFromTag( $tUIAEH_NotificationEventHandler )
EndFunc

#cs
; Insert the two functions here in user code

; This is the function that receives events
Func UIAEH_NotificationEventHandler_HandleNotificationEvent( $pSelf, $pSender, $iKind, $iProcessing, $pDisplayStr, $pActivityId ) ; Ret: long  Par: ptr;long;long;ptr;ptr
  ConsoleWrite( @CRLF & "UIAEH_NotificationEventHandler_HandleNotificationEvent: $iKind = " & $aNotificationKindNames[$iKind] & @CRLF )
  ConsoleWrite( "UIAEH_NotificationEventHandler_HandleNotificationEvent: $iProcessing = " & $aNotificationProcessingNames[$iProcessing] & @CRLF )
  ConsoleWrite( "UIAEH_NotificationEventHandler_HandleNotificationEvent: $sDisplayStr = " & UIA_String( $pDisplayStr ) & @CRLF )
  ConsoleWrite( "UIAEH_NotificationEventHandler_HandleNotificationEvent: $sActivityId = " & UIA_String( $pActivityId ) & @CRLF )
  Local $oSender = ObjCreateInterface( $pSender, $sIID_IUIAutomationElement9, $dtag_IUIAutomationElement9 ) ; Windows 10 Last
  $oSender.AddRef()
  ConsoleWrite( "Title     = " & UIAEH_GetCurrentPropertyValue( $oSender, $UIA_NamePropertyId ) & @CRLF & _
                "Class     = " & UIAEH_GetCurrentPropertyValue( $oSender, $UIA_ClassNamePropertyId ) & @CRLF & _
                "Ctrl type = " & UIAEH_GetCurrentPropertyValue( $oSender, $UIA_ControlTypePropertyId ) & @CRLF & _
                "Ctrl name = " & UIAEH_GetCurrentPropertyValue( $oSender, $UIA_LocalizedControlTypePropertyId ) & @CRLF & _
                "Handle    = " & "0x" & Hex( UIAEH_GetCurrentPropertyValue( $oSender, $UIA_NativeWindowHandlePropertyId ) ) & @CRLF & _
                "Value     = " & UIAEH_GetCurrentPropertyValue( $oSender, $UIA_ValueValuePropertyId ) & @CRLF  )
  Return 0x00000000 ; $S_OK
  #forceref $pSelf
EndFunc

; Auxiliary function (for simple properties only)
; There must be only one instance of this function
Func UIAEH_GetCurrentPropertyValue( $oSender, $iPropertyId )
  Local $vPropertyValue
  $oSender.GetCurrentPropertyValue( $iPropertyId, $vPropertyValue )
  Return $vPropertyValue
EndFunc
#ce

Func UIAEH_NotificationEventHandler_QueryInterface( $pSelf, $pRIID, $pObj ) ; Ret: long  Par: ptr;ptr*
  Switch DllCall( "ole32.dll", "int", "StringFromGUID2", "struct*", $pRIID, "wstr", "", "int", 40 )[2]
    Case "{00000000-0000-0000-C000-000000000046}" ; $sIID_IUnknown
      DllStructSetData( DllStructCreate( "ptr", $pObj ), 1, $pSelf )
      UIAEH_NotificationEventHandler_AddRef( $pSelf )
      Return 0x00000000 ; $S_OK
    Case $sIID_IUIAutomationNotificationEventHandler
      ConsoleWrite( "IID_IUIAutomationNotificationEventHandler" & @CRLF )
      DllStructSetData( DllStructCreate( "ptr", $pObj ), 1, $pSelf )
      UIAEH_NotificationEventHandler_AddRef( $pSelf )
      Return 0x00000000 ; $S_OK
    Case Else
      Return 0x80004002 ; $E_NOINTERFACE
  EndSwitch
EndFunc

Func UIAEH_NotificationEventHandler_AddRef( $pSelf ) ; Ret: ulong
  Return 1
  #forceref $pSelf
EndFunc

Func UIAEH_NotificationEventHandler_Release( $pSelf ) ; Ret: ulong
  Return 1
  #forceref $pSelf
EndFunc

An example is shown in Examples\NotificationEventHandlerEx.au3:

#AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7

#AutoIt3Wrapper_UseX64=y

Opt( "MustDeclareVars", 1 )

#include "..\Includes\UIAEH_NotificationEventHandler.au3"

Example()

Func Example()
  UIAEH_NotificationEventHandlerCreate()
  If Not IsObj( $oUIAEH_NotificationEventHandler ) Then Return ConsoleWrite( "$oUIAEH_NotificationEventHandler ERR" & @CRLF )
  ConsoleWrite( "$oUIAEH_NotificationEventHandler OK" & @CRLF )

  Local $oUIAutomation = ObjCreateInterface( $sCLSID_CUIAutomation8, $sIID_IUIAutomation6, $dtag_IUIAutomation6 ) ; Windows 10 Last
  If Not IsObj( $oUIAutomation ) Then Return ConsoleWrite( "$oUIAutomation ERR" & @CRLF )
  ConsoleWrite( "$oUIAutomation OK" & @CRLF )

  Local $pDesktop
  $oUIAutomation.GetRootElement( $pDesktop )
  If Not $pDesktop Then Return ConsoleWrite( "$pDesktop ERR" & @CRLF )
  ConsoleWrite( "$pDesktop OK" & @CRLF )

  Local $iError = $oUIAutomation.AddNotificationEventHandler( $pDesktop, $TreeScope_Subtree, 0, $oUIAEH_NotificationEventHandler )
  If $iError Then Return ConsoleWrite( "AddNotificationEventHandler() ERR" & @CRLF )
  ConsoleWrite( "AddNotificationEventHandler() OK" & @CRLF )

  HotKeySet( "{ESC}", "Quit" )

  While Sleep(10)
  WEnd
EndFunc

Func Quit()
  UIAEH_NotificationEventHandlerDelete()
  Exit
EndFunc

; This is the function that receives events
Func UIAEH_NotificationEventHandler_HandleNotificationEvent( $pSelf, $pSender, $iKind, $iProcessing, $pDisplayStr, $pActivityId ) ; Ret: long  Par: ptr;long;long;ptr;ptr
  ConsoleWrite( @CRLF & "UIAEH_NotificationEventHandler_HandleNotificationEvent: $iKind = " & $aNotificationKindNames[$iKind] & @CRLF )
  ConsoleWrite( "UIAEH_NotificationEventHandler_HandleNotificationEvent: $iProcessing = " & $aNotificationProcessingNames[$iProcessing] & @CRLF )
  ConsoleWrite( "UIAEH_NotificationEventHandler_HandleNotificationEvent: $sDisplayStr = " & UIA_String( $pDisplayStr ) & @CRLF )
  ConsoleWrite( "UIAEH_NotificationEventHandler_HandleNotificationEvent: $sActivityId = " & UIA_String( $pActivityId ) & @CRLF )
  Local $oSender = ObjCreateInterface( $pSender, $sIID_IUIAutomationElement9, $dtag_IUIAutomationElement9 ) ; Windows 10 Last
  $oSender.AddRef()
  ConsoleWrite( "Title     = " & UIAEH_GetCurrentPropertyValue( $oSender, $UIA_NamePropertyId ) & @CRLF & _
                "Class     = " & UIAEH_GetCurrentPropertyValue( $oSender, $UIA_ClassNamePropertyId ) & @CRLF & _
                "Ctrl type = " & UIAEH_GetCurrentPropertyValue( $oSender, $UIA_ControlTypePropertyId ) & @CRLF & _
                "Ctrl name = " & UIAEH_GetCurrentPropertyValue( $oSender, $UIA_LocalizedControlTypePropertyId ) & @CRLF & _
                "Handle    = " & "0x" & Hex( UIAEH_GetCurrentPropertyValue( $oSender, $UIA_NativeWindowHandlePropertyId ) ) & @CRLF & _
                "Value     = " & UIAEH_GetCurrentPropertyValue( $oSender, $UIA_ValueValuePropertyId ) & @CRLF  )
  Return 0x00000000 ; $S_OK
  #forceref $pSelf
EndFunc

; Auxiliary function (for simple properties only)
; There must be only one instance of this function
Func UIAEH_GetCurrentPropertyValue( $oSender, $iPropertyId )
  Local $vPropertyValue
  $oSender.GetCurrentPropertyValue( $iPropertyId, $vPropertyValue )
  Return $vPropertyValue
EndFunc

Because $pDisplayStr and $pActivityId are Microsoft BSTRs, a new function UIA_String( $pBSTR ) has been added in UIA_Functions.au3 to convert BSTRs to AutoIt strings.

Output in SciTE console (creation):

Func UIAEH_NotificationEventHandler_QueryInterface( $pSelf ) ; Ret: long  Par: ptr;ptr
EndFunc
0

Func UIAEH_NotificationEventHandler_AddRef( $pSelf ) ; Ret: dword
EndFunc
0

Func UIAEH_NotificationEventHandler_Release( $pSelf ) ; Ret: dword
EndFunc
0

Func UIAEH_NotificationEventHandler_HandleNotificationEvent( $pSelf ) ; Ret: long  Par: ptr;long;long;ptr;ptr
EndFunc
0

$oUIAEH_NotificationEventHandler OK
$oUIAutomation OK
$pDesktop OK
IID_IUIAutomationNotificationEventHandler
AddNotificationEventHandler() OK

Output in SciTE console (Windows 10 Calculator):

UIAEH_NotificationEventHandler_HandleNotificationEvent: $iKind = $NotificationKind_ActionCompleted
UIAEH_NotificationEventHandler_HandleNotificationEvent: $iProcessing = $NotificationProcessing_ImportantMostRecent
UIAEH_NotificationEventHandler_HandleNotificationEvent: $sDisplayStr = Standard Lommeregnertilstand
UIAEH_NotificationEventHandler_HandleNotificationEvent: $sActivityId = CategoryNameChanged
Title     = 
Class     = TextBlock
Ctrl type = 50020
Ctrl name = sende sms
Handle    = 0x00000000
Value     = 

UIAEH_NotificationEventHandler_HandleNotificationEvent: $iKind = $NotificationKind_Other
UIAEH_NotificationEventHandler_HandleNotificationEvent: $iProcessing = $NotificationProcessing_ImportantMostRecent
UIAEH_NotificationEventHandler_HandleNotificationEvent: $sDisplayStr = Skærm er 7
UIAEH_NotificationEventHandler_HandleNotificationEvent: $sActivityId = DisplayUpdated
Title     = 
Class     = TextBlock
Ctrl type = 50020
Ctrl name = sende sms
Handle    = 0x00000000
Value     = 

UIAEH_NotificationEventHandler_HandleNotificationEvent: $iKind = $NotificationKind_Other
UIAEH_NotificationEventHandler_HandleNotificationEvent: $iProcessing = $NotificationProcessing_ImportantMostRecent
UIAEH_NotificationEventHandler_HandleNotificationEvent: $sDisplayStr = Skærm er 78
UIAEH_NotificationEventHandler_HandleNotificationEvent: $sActivityId = DisplayUpdated
Title     = 
Class     = TextBlock
Ctrl type = 50020
Ctrl name = sende sms
Handle    = 0x00000000
Value     = 

UIAEH_NotificationEventHandler_HandleNotificationEvent: $iKind = $NotificationKind_Other
UIAEH_NotificationEventHandler_HandleNotificationEvent: $iProcessing = $NotificationProcessing_ImportantMostRecent
UIAEH_NotificationEventHandler_HandleNotificationEvent: $sDisplayStr = Skærm er 789
UIAEH_NotificationEventHandler_HandleNotificationEvent: $sActivityId = DisplayUpdated
Title     = 
Class     = TextBlock
Ctrl type = 50020
Ctrl name = sende sms
Handle    = 0x00000000
Value     = 

UIAEH_NotificationEventHandler_HandleNotificationEvent: $iKind = $NotificationKind_Other
UIAEH_NotificationEventHandler_HandleNotificationEvent: $iProcessing = $NotificationProcessing_ImportantMostRecent
UIAEH_NotificationEventHandler_HandleNotificationEvent: $sDisplayStr = Skærm er 789 gange
UIAEH_NotificationEventHandler_HandleNotificationEvent: $sActivityId = DisplayUpdated
Title     = 
Class     = TextBlock
Ctrl type = 50020
Ctrl name = sende sms
Handle    = 0x00000000
Value     = 

UIAEH_NotificationEventHandler_HandleNotificationEvent: $iKind = $NotificationKind_Other
UIAEH_NotificationEventHandler_HandleNotificationEvent: $iProcessing = $NotificationProcessing_ImportantMostRecent
UIAEH_NotificationEventHandler_HandleNotificationEvent: $sDisplayStr = Skærm er 2
UIAEH_NotificationEventHandler_HandleNotificationEvent: $sActivityId = DisplayUpdated
Title     = 
Class     = TextBlock
Ctrl type = 50020
Ctrl name = sende sms
Handle    = 0x00000000
Value     = 

UIAEH_NotificationEventHandler_HandleNotificationEvent: $iKind = $NotificationKind_Other
UIAEH_NotificationEventHandler_HandleNotificationEvent: $iProcessing = $NotificationProcessing_ImportantMostRecent
UIAEH_NotificationEventHandler_HandleNotificationEvent: $sDisplayStr = Skærm er 1.578
UIAEH_NotificationEventHandler_HandleNotificationEvent: $sActivityId = DisplayUpdated
Title     = 
Class     = TextBlock
Ctrl type = 50020
Ctrl name = sende sms
Handle    = 0x00000000
Value     = 

UIAEH_NotificationEventHandler_HandleNotificationEvent: $iKind = $NotificationKind_ActionCompleted
UIAEH_NotificationEventHandler_HandleNotificationEvent: $iProcessing = $NotificationProcessing_ImportantMostRecent
UIAEH_NotificationEventHandler_HandleNotificationEvent: $sDisplayStr = Den viste værdi er kopieret til udklipsholder
UIAEH_NotificationEventHandler_HandleNotificationEvent: $sActivityId = DisplayCopied
Title     = 
Class     = TextBlock
Ctrl type = 50020
Ctrl name = sende sms
Handle    = 0x00000000
Value     =

Output in SciTE console (Microsoft Edge):

UIAEH_NotificationEventHandler_HandleNotificationEvent: $iKind = $NotificationKind_ActionCompleted
UIAEH_NotificationEventHandler_HandleNotificationEvent: $iProcessing = $NotificationProcessing_ImportantMostRecent
UIAEH_NotificationEventHandler_HandleNotificationEvent: $sDisplayStr = Loading page
UIAEH_NotificationEventHandler_HandleNotificationEvent: $sActivityId = LoadingPageBeginsActivityId
Title     = 
Class     = ScrollViewer
Ctrl type = 50033
Ctrl name = pane
Handle    = 0x00000000
Value     = 

UIAEH_NotificationEventHandler_HandleNotificationEvent: $iKind = $NotificationKind_ActionCompleted
UIAEH_NotificationEventHandler_HandleNotificationEvent: $iProcessing = $NotificationProcessing_ImportantMostRecent
UIAEH_NotificationEventHandler_HandleNotificationEvent: $sDisplayStr = Loading complete
UIAEH_NotificationEventHandler_HandleNotificationEvent: $sActivityId = LoadingPageCompleteActivityId
Title     = 
Class     = ScrollViewer
Ctrl type = 50033
Ctrl name = pane
Handle    = 0x00000000
Value     = 

UIAEH_NotificationEventHandler_HandleNotificationEvent: $iKind = $NotificationKind_ActionCompleted
UIAEH_NotificationEventHandler_HandleNotificationEvent: $iProcessing = $NotificationProcessing_ImportantMostRecent
UIAEH_NotificationEventHandler_HandleNotificationEvent: $sDisplayStr = Loading page
UIAEH_NotificationEventHandler_HandleNotificationEvent: $sActivityId = LoadingPageBeginsActivityId
Title     = 
Class     = ScrollViewer
Ctrl type = 50033
Ctrl name = pane
Handle    = 0x00000000
Value     = 

UIAEH_NotificationEventHandler_HandleNotificationEvent: $iKind = $NotificationKind_ActionCompleted
UIAEH_NotificationEventHandler_HandleNotificationEvent: $iProcessing = $NotificationProcessing_ImportantMostRecent
UIAEH_NotificationEventHandler_HandleNotificationEvent: $sDisplayStr = Loading complete
UIAEH_NotificationEventHandler_HandleNotificationEvent: $sActivityId = LoadingPageCompleteActivityId
Title     = 
Class     = ScrollViewer
Ctrl type = 50033
Ctrl name = pane
Handle    = 0x00000000
Value     = 

UIAEH_NotificationEventHandler_HandleNotificationEvent: $iKind = $NotificationKind_ActionCompleted
UIAEH_NotificationEventHandler_HandleNotificationEvent: $iProcessing = $NotificationProcessing_ImportantMostRecent
UIAEH_NotificationEventHandler_HandleNotificationEvent: $sDisplayStr = Loading page
UIAEH_NotificationEventHandler_HandleNotificationEvent: $sActivityId = LoadingPageBeginsActivityId
Title     = 
Class     = ScrollViewer
Ctrl type = 50033
Ctrl name = pane
Handle    = 0x00000000
Value     = 

UIAEH_NotificationEventHandler_HandleNotificationEvent: $iKind = $NotificationKind_ActionCompleted
UIAEH_NotificationEventHandler_HandleNotificationEvent: $iProcessing = $NotificationProcessing_ImportantMostRecent
UIAEH_NotificationEventHandler_HandleNotificationEvent: $sDisplayStr = Loading complete
UIAEH_NotificationEventHandler_HandleNotificationEvent: $sActivityId = LoadingPageCompleteActivityId
Title     = 
Class     = ScrollViewer
Ctrl type = 50033
Ctrl name = pane
Handle    = 0x00000000
Value     = 

UIAEH_NotificationEventHandler_HandleNotificationEvent: $iKind = $NotificationKind_ActionCompleted
UIAEH_NotificationEventHandler_HandleNotificationEvent: $iProcessing = $NotificationProcessing_ImportantMostRecent
UIAEH_NotificationEventHandler_HandleNotificationEvent: $sDisplayStr = Loading page
UIAEH_NotificationEventHandler_HandleNotificationEvent: $sActivityId = LoadingPageBeginsActivityId
Title     = 
Class     = ScrollViewer
Ctrl type = 50033
Ctrl name = pane
Handle    = 0x00000000
Value     = 

UIAEH_NotificationEventHandler_HandleNotificationEvent: $iKind = $NotificationKind_ActionCompleted
UIAEH_NotificationEventHandler_HandleNotificationEvent: $iProcessing = $NotificationProcessing_ImportantMostRecent
UIAEH_NotificationEventHandler_HandleNotificationEvent: $sDisplayStr = Loading complete
UIAEH_NotificationEventHandler_HandleNotificationEvent: $sActivityId = LoadingPageCompleteActivityId
Title     = 
Class     = ScrollViewer
Ctrl type = 50033
Ctrl name = pane
Handle    = 0x00000000
Value     = 

UIAEH_NotificationEventHandler_HandleNotificationEvent: $iKind = $NotificationKind_ActionCompleted
UIAEH_NotificationEventHandler_HandleNotificationEvent: $iProcessing = $NotificationProcessing_ImportantMostRecent
UIAEH_NotificationEventHandler_HandleNotificationEvent: $sDisplayStr = Going back
UIAEH_NotificationEventHandler_HandleNotificationEvent: $sActivityId = GoingBackActivityId
Title     = Back
Class     = Button
Ctrl type = 50000
Ctrl name = button
Handle    = 0x00000000
Value     = 

UIAEH_NotificationEventHandler_HandleNotificationEvent: $iKind = $NotificationKind_ActionCompleted
UIAEH_NotificationEventHandler_HandleNotificationEvent: $iProcessing = $NotificationProcessing_ImportantMostRecent
UIAEH_NotificationEventHandler_HandleNotificationEvent: $sDisplayStr = Loading page
UIAEH_NotificationEventHandler_HandleNotificationEvent: $sActivityId = LoadingPageBeginsActivityId
Title     = 
Class     = ScrollViewer
Ctrl type = 50033
Ctrl name = pane
Handle    = 0x00000000
Value     = 

UIAEH_NotificationEventHandler_HandleNotificationEvent: $iKind = $NotificationKind_ActionCompleted
UIAEH_NotificationEventHandler_HandleNotificationEvent: $iProcessing = $NotificationProcessing_ImportantMostRecent
UIAEH_NotificationEventHandler_HandleNotificationEvent: $sDisplayStr = Loading complete
UIAEH_NotificationEventHandler_HandleNotificationEvent: $sActivityId = LoadingPageCompleteActivityId
Title     = 
Class     = ScrollViewer
Ctrl type = 50033
Ctrl name = pane
Handle    = 0x00000000
Value     = 

UIAEH_NotificationEventHandler_HandleNotificationEvent: $iKind = $NotificationKind_ActionCompleted
UIAEH_NotificationEventHandler_HandleNotificationEvent: $iProcessing = $NotificationProcessing_ImportantMostRecent
UIAEH_NotificationEventHandler_HandleNotificationEvent: $sDisplayStr = Going back
UIAEH_NotificationEventHandler_HandleNotificationEvent: $sActivityId = GoingBackActivityId
Title     = Back
Class     = Button
Ctrl type = 50000
Ctrl name = button
Handle    = 0x00000000
Value     = 

UIAEH_NotificationEventHandler_HandleNotificationEvent: $iKind = $NotificationKind_ActionCompleted
UIAEH_NotificationEventHandler_HandleNotificationEvent: $iProcessing = $NotificationProcessing_ImportantMostRecent
UIAEH_NotificationEventHandler_HandleNotificationEvent: $sDisplayStr = Loading page
UIAEH_NotificationEventHandler_HandleNotificationEvent: $sActivityId = LoadingPageBeginsActivityId
Title     = 
Class     = ScrollViewer
Ctrl type = 50033
Ctrl name = pane
Handle    = 0x00000000
Value     = 

UIAEH_NotificationEventHandler_HandleNotificationEvent: $iKind = $NotificationKind_ActionCompleted
UIAEH_NotificationEventHandler_HandleNotificationEvent: $iProcessing = $NotificationProcessing_ImportantMostRecent
UIAEH_NotificationEventHandler_HandleNotificationEvent: $sDisplayStr = Loading complete
UIAEH_NotificationEventHandler_HandleNotificationEvent: $sActivityId = LoadingPageCompleteActivityId
Title     = 
Class     = ScrollViewer
Ctrl type = 50033
Ctrl name = pane
Handle    = 0x00000000
Value     = 

UIAEH_NotificationEventHandler_HandleNotificationEvent: $iKind = $NotificationKind_ActionCompleted
UIAEH_NotificationEventHandler_HandleNotificationEvent: $iProcessing = $NotificationProcessing_ImportantMostRecent
UIAEH_NotificationEventHandler_HandleNotificationEvent: $sDisplayStr = Closing tab
UIAEH_NotificationEventHandler_HandleNotificationEvent: $sActivityId = ClosingTabActivityId
Title     = AutoIt Example Scripts - AutoIt Forums tab
Class     = GridViewItem
Ctrl type = 50025
Ctrl name = 
Handle    = 0x00000000
Value     =


AutomationEventHandler
For the existing AutomationEventHandler and for the other existing event handlers, comment lines have been added in both the UDF and the example about which version of the UIA objects to use. Comment lines are added like this:

Local $oUIAutomation = ObjCreateInterface( $sCLSID_CUIAutomation,  $sIID_IUIAutomation,  $dtag_IUIAutomation  ) ; Windows 7
;Local $oUIAutomation = ObjCreateInterface( $sCLSID_CUIAutomation8, $sIID_IUIAutomation2, $dtag_IUIAutomation2 ) ; Windows 8
;Local $oUIAutomation = ObjCreateInterface( $sCLSID_CUIAutomation8, $sIID_IUIAutomation3, $dtag_IUIAutomation3 ) ; Windows 8.1
;Local $oUIAutomation = ObjCreateInterface( $sCLSID_CUIAutomation8, $sIID_IUIAutomation3, $dtag_IUIAutomation3 ) ; Windows 10 First
;Local $oUIAutomation = ObjCreateInterface( $sCLSID_CUIAutomation8, $sIID_IUIAutomation6, $dtag_IUIAutomation6 ) ; Windows 10 Last
Local $oSender = ObjCreateInterface( $pSender, $sIID_IUIAutomationElement,  $dtag_IUIAutomationElement  ) ; Windows 7
;Local $oSender = ObjCreateInterface( $pSender, $sIID_IUIAutomationElement2, $dtag_IUIAutomationElement2 ) ; Windows 8
;Local $oSender = ObjCreateInterface( $pSender, $sIID_IUIAutomationElement3, $dtag_IUIAutomationElement3 ) ; Windows 8.1
;Local $oSender = ObjCreateInterface( $pSender, $sIID_IUIAutomationElement4, $dtag_IUIAutomationElement4 ) ; Windows 10 First
;Local $oSender = ObjCreateInterface( $pSender, $sIID_IUIAutomationElement9, $dtag_IUIAutomationElement9 ) ; Windows 10 Last


UIAEHEvents.au3 updates
In order for UI Automation Event Monitor to be able to detect new events and property changes, the code has been updated to handle different Windows versions and thus different versions of the UIA objects. Handling multiple versions of Windows and multiple versions of the UIA objects is the same as in UIASpy. Through a new Options menu you can execute code that fits a particular Windows version.

Note that under Windows 7 and earlier versions, only the original four event handlers (AutomationEventHandler, FocusChangedEventHandler, PropertyChangedEventHandler, StructureChangedEventHandler) introduced in Windows 7 can be used.

In addition, some minor errors have been fixed and some of the code has been tightened up.


New zip-file at bottom of first post.

Edited by LarsJ

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...