This commit is contained in:
Jonathan Jenne
2019-08-09 17:12:34 +02:00
parent ee2cacb6cd
commit 16a6febb34
21 changed files with 531 additions and 402 deletions

View File

@@ -0,0 +1,39 @@
Imports System.Windows.Automation
Imports System.Windows.Automation.Automation
Imports DigitalData.Modules.Logging
Public Class ClassAutomation
Public Property AutomationId As String = String.Empty
Public Property FrameworkId As String = String.Empty
Private _focusHandler As AutomationFocusChangedEventHandler = Nothing
Private _LogConfig As LogConfig
Private _Logger As Logger
Public Sub New(LogConfig As LogConfig)
_LogConfig = LogConfig
_Logger = LogConfig.GetLogger()
_focusHandler = New AutomationFocusChangedEventHandler(AddressOf OnFocusChange)
AddAutomationFocusChangedEventHandler(_focusHandler)
End Sub
Public Sub [RemoveHandler]()
If _focusHandler IsNot Nothing Then
RemoveAutomationFocusChangedEventHandler(_focusHandler)
End If
End Sub
Public Sub OnFocusChange(src As Object, e As AutomationFocusChangedEventArgs)
Try
Dim oElement As AutomationElement = src
If oElement IsNot Nothing AndAlso oElement IsNot Nothing Then
AutomationId = oElement.Current.AutomationId
FrameworkId = oElement.Current.FrameworkId
End If
Catch ex As Exception
Logger.Error(ex)
End Try
End Sub
End Class