check if current control belongs to current process

This commit is contained in:
Jonathan Jenne 2019-10-25 13:27:34 +02:00
parent 1f280b73a6
commit c80c5aea78

View File

@ -205,7 +205,7 @@ Public Class ProfileFilter
Return oProfiles
End Function
Public Function FilterProfilesByFocusedControlLocation(Profiles As List(Of ProfileData), ClipboardContents As String, WindowHandle As IntPtr) As List(Of ProfileData)
Public Function FilterProfilesByFocusedControl(Profiles As List(Of ProfileData), ClipboardContents As String, WindowHandle As IntPtr) As List(Of ProfileData)
Dim oFilteredProfiles As New List(Of ProfileData)
Dim oWindow As New Window(_LogConfig)
@ -221,6 +221,18 @@ Public Class ProfileFilter
For Each oControl In oProfile.Controls
Dim oFound As Boolean = False
' If current control does not belong to the current process, skip it
Try
Dim oFocusedWindow As Window.WindowInfo = oWindow.GetWindowInfo()
If oFocusedWindow.ProcessName <> oControl.ProcessName Then
Continue For
End If
Catch ex As Exception
_Logger.Error(ex)
End Try
' If control name is empty, use coordinates
If oControl.ControlName Is Nothing OrElse oControl.ControlName = String.Empty Then
Dim oControlBounds As Dictionary(Of String, Window.RectangleInfo)
@ -471,6 +483,7 @@ Public Class ProfileFilter
If oRow.Item("PROFILE_ID") = ProfileId Then
oControlList.Add(New ControlData() With {
.Guid = oRow.Item("GUID"),
.ProcessName = NotNull(oRow.Item("PROCESS_NAME"), String.Empty),
.ControlName = NotNull(oRow.Item("CONTROL_NAME"), String.Empty),
.Description = NotNull(oRow.Item("DESCRIPTION"), String.Empty),
.WindowId = oRow.Item("WINDOW_ID"),