From ca4683a05e9f2e18ced956b397e3d8ccc1ee78d7 Mon Sep 17 00:00:00 2001 From: Jonathan Jenne Date: Mon, 23 Sep 2019 16:48:56 +0200 Subject: [PATCH] improve profile match debugging --- app/DD_Clipboard_Searcher/ClassInit.vb | 2 +- .../ClassProfileFilter.vb | 390 +++++++----------- app/DD_Clipboard_Searcher/frmStart.vb | 14 +- 3 files changed, 169 insertions(+), 237 deletions(-) diff --git a/app/DD_Clipboard_Searcher/ClassInit.vb b/app/DD_Clipboard_Searcher/ClassInit.vb index f4f9c1e..9acfbf3 100644 --- a/app/DD_Clipboard_Searcher/ClassInit.vb +++ b/app/DD_Clipboard_Searcher/ClassInit.vb @@ -241,7 +241,7 @@ Public Class ClassInit If DT_USER_PROFILES Is Nothing OrElse DT_USER_PROFILES.Rows.Count = 0 Then MsgBox("No profiles configured for this user so far!", MsgBoxStyle.Exclamation) Else - oSql = $"SELECT T.* FROM TBCW_PROFILE_PROCESS T, VWCW_USER_PROFILE T1 WHERE T.PROFILE_ID = T1.GUID AND T1.USER_ID = {USER_ID}" + oSql = $"SELECT DISTINCT T.GUID, T.PROFILE_ID,T.PROC_NAME FROM TBCW_PROFILE_PROCESS T, VWCW_USER_PROFILE T1 WHERE T.PROFILE_ID = T1.GUID AND T1.USER_ID = {USER_ID}" DTPROFILE_REL_PROCESS = Database.GetDatatable(oSql) oSql = $"SELECT * FROM VWCW_PROFILE_REL_WINDOW WHERE USER_ID = {USER_ID}" diff --git a/app/DD_Clipboard_Searcher/ClassProfileFilter.vb b/app/DD_Clipboard_Searcher/ClassProfileFilter.vb index 8af92f6..9250fff 100644 --- a/app/DD_Clipboard_Searcher/ClassProfileFilter.vb +++ b/app/DD_Clipboard_Searcher/ClassProfileFilter.vb @@ -1,7 +1,5 @@ Imports System.Text.RegularExpressions -Imports DD_Clipboard_Watcher.ClassWindowAPI Imports DigitalData.Modules.Language.Utils -Imports System.Windows.Automation Imports DigitalData.Modules.Windows Public Class ClassProfileFilter @@ -10,7 +8,7 @@ Public Class ClassProfileFilter Private _WindowTable As DataTable Private _ControlTable As DataTable Private _Profiles As List(Of ProfileData) - Private _DebugData As DebugData + Private _TreeView As TreeView Class ProfileData Public Guid As Integer @@ -31,12 +29,27 @@ Public Class ClassProfileFilter Public MatchedControlID As Integer = 0 Public SelectCommand As String + Public Overrides Function Equals(obj As Object) As Boolean + Return Guid = DirectCast(obj, ProfileData).Guid + End Function + + Public Overrides Function GetHashCode() As Integer + Return Guid.ToString.GetHashCode() + End Function End Class Class ProcessData Public Guid As Integer Public PROFILE_ID As Integer Public ProcessName As String Public IsMatched As Boolean = False + + Public Overrides Function Equals(obj As Object) As Boolean + Return Guid = DirectCast(obj, ProcessData).Guid + End Function + + Public Overrides Function GetHashCode() As Integer + Return Guid.ToString.GetHashCode() + End Function End Class Class WindowData Public Guid As Integer @@ -47,7 +60,6 @@ Public Class ClassProfileFilter Public IsMatched As Boolean = False End Class - Class ControlData Public Guid As Integer Public WindowId As Integer @@ -61,36 +73,26 @@ Public Class ClassProfileFilter Public BottomLeft As ControlBounds Public BottomRight As ControlBounds End Class - Class ControlBounds Public Top As Integer Public Bottom As Integer Public Left As Integer Public Right As Integer End Class - - ' TODO: Fill this Class!!!! :D - Class DebugData - Public ProcessMatch As List(Of String) - Public ClipboardMatch As List(Of String) - Public WindowMatch As List(Of String) - Public WindowRegexMatch As List(Of String) - End Class - Public ReadOnly Property Profiles As List(Of ProfileData) Get Return _Profiles End Get End Property - Public Sub New(ProfileDatatable As DataTable, ProcessTable As DataTable, WindowDatatable As DataTable, ControlDatatable As DataTable) + Public Sub New(ProfileDatatable As DataTable, ProcessTable As DataTable, WindowDatatable As DataTable, ControlDatatable As DataTable, TreeView As TreeView) Try - _DebugData = New DebugData() _ProfileTable = ProfileDatatable _ProcessTable = ProcessTable _WindowTable = WindowDatatable _ControlTable = ControlDatatable _Profiles = TransformProfiles() + _TreeView = TreeView Catch ex As Exception Logger.Error(ex) Throw ex @@ -109,50 +111,117 @@ Public Class ClassProfileFilter End If End Function - Private Function Node_Get_Lowest_Node(NodeTag As String) As TreeNode - Dim oExit = False - Dim oParentNode As TreeNode - For Each oTreeNode As TreeNode In CurrMatchTreeView.Nodes - For Each oNodes As TreeNode In oTreeNode.Nodes - If oExit = True Then Exit For - If oNodes.Tag = NodeTag Then - oParentNode = oNodes - oExit = True - Exit For - End If - Next + Private Function FindNodeByTag(ByVal nodes As TreeNodeCollection, ByVal Tag As String) As TreeNode + For Each node As TreeNode In nodes + If (node.Tag.Equals(Tag)) Then + Return node + End If + + Dim oNext As TreeNode = FindNodeByTag(node.Nodes, Tag) + If oNext IsNot Nothing Then + Return oNext + End If Next - Dim olowestNode As TreeNode = GetLowestNode(oParentNode) + Return Nothing + End Function - Return olowestNode + Private Function GetMatchText(IsMatch As Boolean) + Return IIf(IsMatch, "MATCH", "NO MATCH") + End Function + + Private Function GetMatchColor(IsMatch As Boolean) + Return IIf(IsMatch, Color.LightGreen, Color.LightCoral) + End Function + + Private Function NewProfileNode(Profile As ProfileData) As TreeNode + Dim oNode As New TreeNode() With { + .Text = $"Profile: {Profile.Name}", + .ImageIndex = 0, + .Tag = Profile.Name & "-PROFILE" + } + + Return oNode + End Function + + Private Function NewClipboardRegexNode(Profile As ProfileData, IsMatch As Boolean) As TreeNode + Dim oText = $"{GetMatchText(IsMatch)} on Global Clipboard Regex {Profile.Regex}: {IsMatch.ToString}" + + Dim oNode As New TreeNode() With { + .Text = oText, + .ImageIndex = 1, + .Tag = Profile.Name & "-REGEX", + .BackColor = GetMatchColor(IsMatch) + } + + Return oNode + End Function + Private Function NewProcessNode(Profile As ProfileData, Process As ProcessData, IsMatch As Boolean) As TreeNode + Dim oMatchText = IIf(IsMatch, "MATCH", "NO MATCH") + Dim oText = $"{GetMatchText(IsMatch)} on ProcessName {Process.ProcessName}: {IsMatch.ToString}" + + Dim oNode As New TreeNode() With { + .Text = oText, + .ImageIndex = 4, + .Tag = Process.Guid & "-PROCESS", + .BackColor = GetMatchColor(IsMatch) + } + + Return oNode + End Function + + Private Function NewWindowNode(Profile As ProfileData, Window As WindowData, IsMatch As Boolean) As TreeNode + Dim oMatchText = IIf(IsMatch, "MATCH", "NO MATCH") + Dim oText = $"{GetMatchText(IsMatch)} on WindowTitle {Window.Title}: {IsMatch.ToString}" + + Dim oNode As New TreeNode() With { + .Text = oText, + .ImageIndex = 3, + .Tag = Window.Guid & "-WINDOW", + .BackColor = GetMatchColor(IsMatch) + } + + Return oNode + End Function + + Private Function NewControlNode(Profile As ProfileData, Control As ControlData, IsMatch As Boolean) As TreeNode + Dim oMatchText = IIf(IsMatch, "MATCH", "NO MATCH") + Dim oText = $"{GetMatchText(IsMatch)} on Control {Control.Description}: {IsMatch.ToString}" + + Dim oNode As New TreeNode() With { + .Text = oText, + .ImageIndex = 2, + .Tag = Control.Guid & "-CONTROL", + .BackColor = GetMatchColor(IsMatch) + } + + Return oNode End Function Public Function FilterProfilesByClipboardRegex(Profiles As List(Of ProfileData), ClipboardContents As String) As List(Of ProfileData) Dim oFilteredProfiles As New List(Of ProfileData) + + Dim oRootNode As TreeNode = New TreeNode() With { + .Text = $"Suche nach '{ClipboardContents}'", + .Tag = "ROOT" + } + _TreeView.Nodes.Add(oRootNode) + For Each oProfile In Profiles Logger.Debug("Current Profile: {0}", oProfile.Name) - Dim oNode As New TreeNode() With { - .Text = $"Profile: {oProfile.Name}", - .ImageIndex = 0, - .Tag = oProfile.Name & "-PROFILE" - } - CurrMatchTreeView.Nodes.Add(oNode) + Dim oNode = NewProfileNode(oProfile) + oRootNode.Nodes.Add(oNode) Try Dim oRegex As New Regex(oProfile.Regex) Dim oMatch = oRegex.Match(ClipboardContents) If oMatch.Success Then Logger.Debug("FilterProfilesByClipboardRegex: Clipboard Regex Matched: {0}", ClipboardContents) - 'TODO: Add Debug Data oFilteredProfiles.Add(oProfile) oProfile.IsMatched = True - Dim oSubnode As New TreeNode($"MATCH on Global Clipboard Regex: {oProfile.Regex}") - oSubnode.ImageIndex = 1 - oSubnode.Tag = oProfile.Name & "-REGEX" + Dim oSubnode = NewClipboardRegexNode(oProfile, oMatch.Success) oNode.Nodes.Add(oSubnode) - End If Catch ex As Exception Logger.Warn("Regex '{0}' could not be processed for input '{1}'", oProfile.Regex, ClipboardContents) @@ -172,14 +241,21 @@ Public Class ClassProfileFilter Continue For End If - Dim oProcesses As New List(Of ProcessData) For Each oProcessDef As ProcessData In oProfile.Processes If oProcessDef.PROFILE_ID <> oGuid Then Continue For End If + + Dim oIsMatch = oProcessDef.ProcessName.ToLower = CurrentProcessName.ToLower + Dim oParent = FindNodeByTag(_TreeView.Nodes, oProfile.Name & "-REGEX") + If oParent IsNot Nothing Then + Dim oNode = NewProcessNode(oProfile, oProcessDef, oIsMatch) + oParent.Nodes.Add(oNode) + End If + Logger.Debug($"FilterProfilesByProcess: Checking Profile: {oProfile.Name} ...") - If oProcessDef.ProcessName.ToLower = CurrentProcessName.ToLower Then + If oIsMatch Then Logger.Debug($"Yes...Processname Matched: {oProcessDef.ProcessName}") 'oProfile.MATCH_PROCESSNAME = $"Processname Matched: {oProfile.ProcessName}" 'TODO: Add Debug Data @@ -189,25 +265,7 @@ Public Class ClassProfileFilter oProcesses.Add(oProcessDef) oProfile.IsMatched = True oProfile.MatchedProcessID = oProcessDef.Guid - Dim oParentNode As TreeNode - Dim oExit = False - For Each oTreeNode As TreeNode In CurrMatchTreeView.Nodes - For Each oNodes As TreeNode In oTreeNode.Nodes - If oExit = True Then Exit For - If oNodes.Tag = oProfile.Name & "-REGEX" Then - oParentNode = oNodes - oExit = True - Exit For - End If - Next - Next - - If Not IsNothing(oParentNode) Then - Dim oNode As New TreeNode($"MATCH on Process: {oProcessDef.ProcessName}") - oNode.ImageIndex = 4 - oNode.Tag = oProfile.Name & "-PROCESS" - oParentNode.Nodes.Add(oNode) - End If + End If Next If oFilteredProfiles.Count > 0 Then @@ -245,19 +303,17 @@ Public Class ClassProfileFilter If oMatch.Success Then Logger.Debug("MATCH on WindowTitle: {0}", WindowTitle) - 'TODO: Add Debug Data oProfile.MatchedWindowID = oWindowDef.Guid oWindowDef.IsMatched = True oWindows.Add(oWindowDef) - Dim olowestNode As TreeNode = Node_Get_Lowest_Node(oProfile.Name & "-REGEX") - If Not IsNothing(olowestNode) Then - Dim oNode As New TreeNode($"MATCH on WindowTitle: [{WindowTitle}]") - oNode.ImageIndex = 3 - oNode.Tag = oProfile.Name & "-WINDOW" - olowestNode.Nodes.Add(oNode) - End If - Exit For End If + + Dim oParent = FindNodeByTag(_TreeView.Nodes, oWindowDef.WindowProcessID & "-PROCESS") + If oParent IsNot Nothing Then + Dim oNode = NewWindowNode(oProfile, oWindowDef, oMatch.Success) + oParent.Nodes.Add(oNode) + End If + Catch ex As Exception Logger.Warn("Regex '{0}' could not be processed for input '{1}'", oWindowDef.Regex, WindowTitle) Logger.Error(ex) @@ -290,27 +346,38 @@ Public Class ClassProfileFilter For Each oControl In oProfile.Controls Dim oControlBounds = oWindow.GetFocusedControlLocation(WindowHandle) + Dim oFound As Boolean = False For Each oItem As KeyValuePair(Of String, Window.RectangleInfo) In oControlBounds Select Case oItem.Key Case "TOPLEFT" If oControl.TopLeft.Top = oItem.Value.Top And oControl.TopLeft.Left = oItem.Value.Left Then - oFilteredProfiles.Add(oProfile) + oFound = True End If Case "TOPRIGHT" If oControl.TopRight.Top = oItem.Value.Top And oControl.TopLeft.Right = oItem.Value.Right Then - oFilteredProfiles.Add(oProfile) + oFound = True End If Case "BOTTOMLEFT" If oControl.BottomLeft.Bottom = oItem.Value.Bottom And oControl.TopLeft.Left = oItem.Value.Left Then - oFilteredProfiles.Add(oProfile) + oFound = True End If Case "BOTTOMRIGHT" If oControl.BottomRight.Bottom = oItem.Value.Bottom And oControl.TopLeft.Right = oItem.Value.Right Then - oFilteredProfiles.Add(oProfile) + oFound = True End If End Select Next + + If oFound Then + oFilteredProfiles.Add(oProfile) + End If + + Dim oParent = FindNodeByTag(_TreeView.Nodes, oControl.WindowId & "-WINDOW") + If oParent IsNot Nothing Then + Dim oNode = NewControlNode(oProfile, oControl, oFound) + oParent.Nodes.Add(oNode) + End If Next If oControls.Count > 0 Then @@ -342,24 +409,15 @@ Public Class ClassProfileFilter If oMatch.Success Then Logger.Debug("Window Clipboard Regex Matched: {0}", ClipboardContents) - Dim oResult As TreeNode - For Each oTreeNode In CurrMatchTreeView.Nodes - If Not IsNothing(oResult) Then Exit For - If oTreeNode.Tag = oProfile.Name & "-REGEX" Then - oResult = oTreeNode - End If - Next - If Not IsNothing(oResult) Then - Dim oNode As New TreeNode($"MATCH on WINDOW Clipboard Regex: [{w.Regex}]") - oNode.ImageIndex = 2 - oNode.Tag = oProfile.Name & "-WINDOW_REGEX" - Dim olowestNode As TreeNode = GetLowestNode(oResult) - olowestNode.Nodes.Add(oNode) - End If - oWindows.Add(w) + End If - + Dim oResult As TreeNode = FindNodeByTag(_TreeView.Nodes, oProfile.Name & "-REGEX") + If Not IsNothing(oResult) Then + Dim oNode As New TreeNode($"MATCH on WINDOW Clipboard Regex [{w.Regex}]: {oMatch.Success}") + oNode.ImageIndex = 2 + oNode.Tag = oProfile.Name & "-WINDOW_REGEX" + oResult.Nodes.Add(oNode) End If Catch ex As Exception Logger.Warn("Regex '{0}' could not be processed for input '{1}'", w.Regex, ClipboardContents) @@ -376,147 +434,6 @@ Public Class ClassProfileFilter Return oProfiles End Function - Public Function FilterProfilesByFocusedControl(Profiles As List(Of ProfileData), ClipboardContents As String, ControlFocusresult As String) As List(Of ProfileData) - Dim oWindow As WindowInfo - Dim oFocusedControl As WindowInfo - Dim oFocusedControlName As String = String.Empty - - Try - oWindow = GetWindowInfo() - oFocusedControl = GetFocusedControl(oWindow.hWnd) - - If oFocusedControl Is Nothing Then - Logger.Info("Could not get FocusedControl in Window (Old method) {0}", oWindow.WindowTitle) - oFocusedControlName = String.Empty - Else - oFocusedControlName = oFocusedControl.ControlName - End If - Catch ex As Exception - Logger.Warn("Error while getting Focused control (Old method)") - Logger.Error(ex) - oFocusedControlName = String.Empty - End Try - - Dim oFilteredProfiles As New List(Of ProfileData) - - For Each oProfileMatchedSofar In Profiles - If oProfileMatchedSofar.IsMatched = False Then Continue For - - Logger.Debug("Checking ControlDefinition on profile: {0}", oProfileMatchedSofar.Name) - Logger.Debug("Profile has {0} configured controls", oProfileMatchedSofar.Controls.Count) - - Dim oControlsForMatchedWindow As New List(Of ControlData) - - For Each oControl In oProfileMatchedSofar.Controls - If oControl.WindowId = oProfileMatchedSofar.MatchedWindowID Then - oControlsForMatchedWindow.Add(oControl) - End If - Next - - If oControlsForMatchedWindow.Count = 0 Then - Logger.Debug("Profile has no configured controls. Skipping.") - oFilteredProfiles.Add(oProfileMatchedSofar) - - Dim oNode As New TreeNode($"No Controls configured!") With { - .ImageIndex = 2, - .ForeColor = Color.Blue, - .Tag = oProfileMatchedSofar.Name & "-NOCONTROLCONFIG", - .NodeFont = New Font("Tahoma", 10, FontStyle.Bold) - } - - CurrMatchTreeView.Nodes.Add(oNode) - - Continue For - End If - - Dim oControls As New List(Of ControlData) - - For Each oControlDefinition In oControlsForMatchedWindow - Try - If oControlDefinition.WindowId <> oProfileMatchedSofar.MatchedWindowID Then - Logger.Debug("Current WindowId {0} does not match Control WindowId {1}. Skipping.", oProfileMatchedSofar.MatchedWindowID, oControlDefinition.WindowId) - Continue For - End If - - Logger.Debug($"Working on ControlDefinition: {oControlDefinition.Guid}-{oControlDefinition.ControlName}...") - If oControlDefinition.Regex = String.Empty Then - oProfileMatchedSofar.MatchedControlID = oControlDefinition.Guid - oControlDefinition.IsMatched = True - oControls.Add(oControlDefinition) - Exit For - End If - 'Dim oResult As TreeNode - 'For Each oTreeNode In CurrMatchTreeView.Nodes - ' oResult = NodeFind(oTreeNode, $"Global Clipboard Regex Matched [{oProfile.Regex}]") - 'Next - 'Dim oNode As TreeNode - Dim oNodeCaption As String - 'Dim oAddNode As Boolean = False - Dim oRegex As New Regex(oControlDefinition.Regex) - - Dim oFocusedControlResult As String = "" - - If oControlDefinition.AutomationId <> String.Empty And oControlDefinition.ControlName = String.Empty Then - Logger.Debug($"AutomationID should be used...") - If Not IsNothing(ControlFocusresult) Then - If ControlFocusresult <> String.Empty Then - Logger.Debug($"AutomationID will be used...") - oFocusedControlResult = ControlFocusresult - End If - End If - ElseIf oControlDefinition.AutomationId = String.Empty And oControlDefinition.ControlName <> String.Empty Then - Logger.Debug($"ControlName should be used...") - If Not IsNothing(oFocusedControlName) Then - If oFocusedControlName <> String.Empty Then - Logger.Debug($"ControlName will be used...") - oFocusedControlResult = oFocusedControlName - End If - End If - - End If - If oFocusedControlResult <> String.Empty Then - Dim oControlRegex As New Regex(oControlDefinition.Regex) - Dim oControlMatch = oRegex.Match(oFocusedControlResult) - - If oControlMatch.Success Then - Logger.Debug($"MATCH on Focused Control [{oFocusedControlResult}] with Regex [{oControlDefinition.Regex}]") - oProfileMatchedSofar.IsMatched = True - oProfileMatchedSofar.MatchedControlID = oControlDefinition.Guid - oControlDefinition.IsMatched = True - oControls.Add(oControlDefinition) - Dim olowestNode As TreeNode = Node_Get_Lowest_Node(oProfileMatchedSofar.Name & "-REGEX") - If Not IsNothing(olowestNode) Then - Dim oNode As New TreeNode($"MATCH on Focused Control [{oFocusedControlResult}] with Regex [{oControlDefinition.Regex}]") - oNode.ImageIndex = 2 - oNode.Tag = oProfileMatchedSofar.Name & "-CONTROL" - olowestNode.Nodes.Add(oNode) - End If - Exit For - End If - End If - Catch ex As Exception - Logger.Warn("Regex '{0}' could not be processed for input '{1}'", oControlDefinition.Regex, oFocusedControlName) - Logger.Error(ex) - End Try - Next - - If oControls.Count > 0 Then - oProfileMatchedSofar.Controls = oControls - oFilteredProfiles.Add(oProfileMatchedSofar) - Else - Dim olowestNode As TreeNode = Node_Get_Lowest_Node(oProfileMatchedSofar.Name & "-REGEX") - If Not IsNothing(olowestNode) Then - Dim oNode As New TreeNode($"NO MATCHES on Focused Control, Please check the Config") - oNode.ImageIndex = 2 - oNode.Tag = oProfileMatchedSofar.Name & "-CONTROLNoMatch" - olowestNode.Nodes.Add(oNode) - End If - End If - Next - - Return oFilteredProfiles - End Function - Public Function ClearNotMatchedProfiles(Profiles As List(Of ProfileData)) As List(Of ProfileData) Dim oFilteredProfiles As New List(Of ProfileData) For Each oProfile In Profiles @@ -545,6 +462,7 @@ Public Class ClassProfileFilter oList.Add(New ProfileData() With { .Guid = oRow.Item("GUID"), + .Regex = oRow.Item("REGEX_EXPRESSION"), .Name = NotNull(oRow.Item("NAME"), String.Empty), .Comment = NotNull(oRow.Item("COMMENT"), String.Empty), .ProfileType = NotNull(oRow.Item("PROFILE_TYPE"), String.Empty), @@ -554,6 +472,10 @@ Public Class ClassProfileFilter }) Next + oList = oList. + Distinct(). + ToList() + Return oList End Function @@ -609,6 +531,10 @@ Public Class ClassProfileFilter End If Next + oProcessList = oProcessList. + Distinct(). + ToList() + Return oProcessList End Function Private Function TransformWindows(ProfileId As Integer, WindowDatatable As DataTable) As List(Of WindowData) diff --git a/app/DD_Clipboard_Searcher/frmStart.vb b/app/DD_Clipboard_Searcher/frmStart.vb index ec514fd..f34c2b9 100644 --- a/app/DD_Clipboard_Searcher/frmStart.vb +++ b/app/DD_Clipboard_Searcher/frmStart.vb @@ -102,18 +102,22 @@ Public Class frmStart End If If DT_USER_PROFILES Is Nothing OrElse DT_USER_PROFILES.Rows.Count = 0 Then + Logger.Warn("DT_USER_PROFILES is empty!") Exit Sub End If If DTPROFILE_REL_PROCESS Is Nothing OrElse DTPROFILE_REL_PROCESS.Rows.Count = 0 Then + Logger.Warn("DTPROFILE_REL_PROCESS is empty!") Exit Sub End If If DTPROFILE_REL_WINDOW Is Nothing OrElse DTPROFILE_REL_WINDOW.Rows.Count = 0 Then + Logger.Warn("DTPROFILE_REL_WINDOW is empty!") Exit Sub End If If DTPROFILE_REL_CONTROL Is Nothing OrElse DTPROFILE_REL_CONTROL.Rows.Count = 0 Then + Logger.Warn("DTPROFILE_REL_CONTROL is empty!") Exit Sub End If @@ -122,7 +126,12 @@ Public Class frmStart Dim oProfileFilter As ClassProfileFilter Dim oFocusedControl As IntPtr = FocusedControlinActiveWindow(Handle) Try - oProfileFilter = New ClassProfileFilter(DT_USER_PROFILES, DTPROFILE_REL_PROCESS, DTPROFILE_REL_WINDOW, DTPROFILE_REL_CONTROL) + oProfileFilter = New ClassProfileFilter( + DT_USER_PROFILES, + DTPROFILE_REL_PROCESS, + DTPROFILE_REL_WINDOW, + DTPROFILE_REL_CONTROL, + CurrMatchTreeView) Catch ex As Exception MsgBox("Fehler beim Laden der Profile. Möglicherweise liegt ein Konfigurationsfehler vor.", MsgBoxStyle.Critical, Text) Exit Sub @@ -133,8 +142,6 @@ Public Class frmStart CurrMatchTreeView.ImageList = ImageList1 CurrMatchTreeView.SelectedImageIndex = 0 - - oProfiles = oProfileFilter.FilterProfilesByClipboardRegex(oProfiles, ClipboardContents) oProfiles = oProfileFilter.FilterProfilesByProcess(oProfiles, oWindowInfo.ProcessName) oProfiles = oProfileFilter.FilterWindowsByWindowTitleRegex(oProfiles, oWindowInfo.WindowTitle) @@ -158,7 +165,6 @@ Public Class frmStart ElseIf HotKeyID = HOTKEY_TOGGLE_WATCHER Then Change_Monitoring_State() End If - End Sub Sub CHECK_PROFILE_MATCH() Dim oProfiles = CURRENT_MATCHING_PROFILES