MS WindowTitleMAtch

This commit is contained in:
Digital Data - Marlon Schreiber 2019-07-12 12:21:58 +02:00
parent 6d9f41ea09
commit be1f74ceb0
4 changed files with 59 additions and 23 deletions

View File

@ -74,10 +74,13 @@ Public Class clsHotkey
End Class
Public Shared Sub Refresh_Profile_Links()
Try
Dim sql = String.Format("SELECT * FROM VWCW_USER_PROFILE WHERE USER_ID = {0}", USER_ID)
DT_USER_PROFILES = clsDatabase.Return_Datatable(sql)
Dim oSql = String.Format("SELECT * FROM VWCW_USER_PROFILE WHERE USER_ID = {0}", USER_ID)
DT_USER_PROFILES = clsDatabase.Return_Datatable(oSql)
If DT_USER_PROFILES.Rows.Count = 0 Then
MsgBox("No profiles configured for this user so far!", MsgBoxStyle.Exclamation)
Else
oSql = $"SELECT * FROM VWCW_PROFILE_REL_WINDOW WHERE USER_ID = {USER_ID}"
DTPROFILE_REL_WINDOW = clsDatabase.Return_Datatable(oSql)
End If
Catch ex As Exception
MsgBox("Unexpected Error in Refresh_Profile_Links: " & ex.Message, MsgBoxStyle.Critical)

View File

@ -504,8 +504,14 @@ Public Class frmResultDoc
frmProfileMatch.BringToFront()
End If
Catch ex As Exception
If Not IsNothing(CurrDT_PROFILE_MATCH) Then
If CurrDT_PROFILE_MATCH.Rows.Count > 1 Then
_frmProfileMatch.Show()
_frmProfileMatch.BringToFront()
End If
End If
End Try
End Sub

View File

@ -38,7 +38,7 @@ Public Class frmStart
' .AppendText(String.Concat(vbNewLine, vbNewLine, "Text = '", _
' Clipboard.GetText, "'", vbNewLine, vbNewLine))
'End With
Dim found As Boolean = False
Dim oFound As Boolean = False
CLIPBOARD_TEXT = Clipboard.GetText
Logger.Debug(String.Format(" >>[{0}] Clipboard-Watcher fired for process '{1}'", Now.ToString, CurrPROC_Name), False)
Dim oDTMatchProfiles As DataTable = New DataTable
@ -48,21 +48,43 @@ Public Class frmStart
oDTMatchProfiles.Columns.Add("COMMENT")
For Each oProfileRow As DataRow In DT_USER_PROFILES.Rows
Dim oProfileID = oProfileRow.Item("GUID")
'If found = True Then Exit For
'#### 1st CHECK: PROCESSNAME EQUAL ####
If CurrPROC_Name.ToUpper = oProfileRow.Item("PROC_NAME").ToString.ToUpper Then
Dim regex_expression = oProfileRow.Item("REGEX_EXPRESSION")
Dim regex As New System.Text.RegularExpressions.Regex(regex_expression)
Dim match As System.Text.RegularExpressions.Match = regex.Match(CLIPBOARD_TEXT)
If match.Success Then
'### 2nd CHECK: MATCH ClipboardValue
Dim oRegex_expression = oProfileRow.Item("REGEX_EXPRESSION")
Dim oRegex As New System.Text.RegularExpressions.Regex(oRegex_expression)
Dim oMatch As System.Text.RegularExpressions.Match = oRegex.Match(CLIPBOARD_TEXT)
If oMatch.Success Then
' If match.Groups(0).Value <> CURR_MATCH_RESULT Then
CURR_MATCH_RESULT = match.Groups(0).Value
CURR_MATCH_RESULT = oMatch.Groups(0).Value
If Not IsNothing(CURR_MATCH_RESULT) Then
'#### 3rd CHECK: WindowTitle Match
Dim oMatchWindow As Boolean = True
Dim oCountWindowDefinitions As Integer = 0
For Each oWindowMatchRow As DataRow In DTPROFILE_REL_WINDOW.Rows
If oWindowMatchRow.Item("PROFILE_ID") = oProfileID Then
oCountWindowDefinitions += 1
oRegex_expression = oWindowMatchRow.Item("REGEX")
oRegex = New System.Text.RegularExpressions.Regex(oRegex_expression)
oMatch = oRegex.Match(CURR_FOCUSED_WINDOWNAME)
oMatchWindow = oMatch.Success
If oMatchWindow = True Then
Logger.Debug($"Found a match on windowtitle [{CURR_FOCUSED_WINDOWNAME}]")
Exit For
End If
End If
Next
If oMatchWindow = False Then
Logger.Debug($"Found NO MATCH on windowtitle [{CURR_FOCUSED_WINDOWNAME}], but [{oCountWindowDefinitions}] definitions are configured")
Exit For
End If
'CURR_MATCH_WM_SEARCH = oProfileRow.Item("WD_SEARCH")
Dim oSQL_COUNT As String = oProfileRow.Item("SQL_COUNT_RESULT")
Dim oRESULTDocs As Integer
If oSQL_COUNT <> String.Empty Then
oSQL_COUNT = clsPatterns.ReplaceAllValues(oSQL_COUNT, USER_PRENAME, USER_SURNAME, USER_SHORTNAME, USER_EMAIL, USER_ID, oProfileRow.Item("GUID"))
oSQL_COUNT = clsPatterns.ReplaceAllValues(oSQL_COUNT, USER_PRENAME, USER_SURNAME, USER_SHORTNAME, USER_EMAIL, USER_ID, oProfileID)
Try
oRESULTDocs = ClassDatabase.Execute_Scalar(oSQL_COUNT, MyConnectionString)
Catch ex As Exception
@ -71,13 +93,16 @@ Public Class frmStart
Else
oRESULTDocs = 99998
End If
If (oRESULTDocs <> 99998 And oRESULTDocs <> 99998 And oRESULTDocs <> 0) Then
Dim onewMatchRow As DataRow = oDTMatchProfiles.NewRow
onewMatchRow("GUID") = oProfileRow.Item("GUID")
onewMatchRow("GUID") = oProfileID
onewMatchRow("NAME") = oProfileRow.Item("NAME")
onewMatchRow("COMMENT") = oProfileRow.Item("COMMENT")
onewMatchRow("COUNT") = oRESULTDocs
oDTMatchProfiles.Rows.Add(onewMatchRow)
found = True
oFound = True
End If
End If
'Else
@ -86,12 +111,12 @@ Public Class frmStart
' Exit For
'End If
Else
Logger.Debug(String.Format(" >> {0} - No regex-match for cliboardtext '{1}'", Now.ToString, match.Groups(0).Value), False)
'Logger.Debug(String.Format(" >> {0} - No regex-match for cliboardtext '{1}'", Now.ToString, oMatch.Groups(0).Value), False)
End If
End If
Next
If found = False Then
Logger.Debug(String.Format(" >> {0} - Process '{1}' not configured!", Now.ToString, CurrPROC_Name), False)
If oFound = False Then
Logger.Debug(String.Format(" >> {0} - oFound is false - no match on Clipboardvalue '{1}'!", Now.ToString, CURR_MATCH_RESULT), False)
CurrDT_PROFILE_MATCH = Nothing
Else
CurrDT_PROFILE_MATCH = oDTMatchProfiles
@ -198,7 +223,7 @@ Public Class frmStart
End Sub
Private Sub ReceiveHotKey(ByVal HotKeyID As String) Handles Hotkey.HotKeyPressed
If HotKeyID = 354523017 Then
If Not IsNothing(CURR_MATCH_RESULT) Then
If Not IsNothing(CURR_MATCH_RESULT) And Not IsNothing(CurrDT_PROFILE_MATCH) Then
CHECK_PROFILE_MATCH()
End If
'If Not IsNothing(CURR_MATCH_RESULT) And Not IsNothing(CURR_MATCH_WM_SEARCH) Then

View File

@ -58,6 +58,8 @@ Module modCurrent
Public CLIENT_SELECTED As Integer = 0
Public CurrDT_PROFILE_MATCH As DataTable
Public DTPROFILE_REL_WINDOW As DataTable
Public CURRENT_DT_DOC_SEARCHES As DataTable
Public CURRENT_DT_DATA_SEARCHES As DataTable
Public CurrDocSearch2Load As Object