From 68724748a9e7c17ddfb6c2e9913f713e138c5006 Mon Sep 17 00:00:00 2001 From: Jonathan Jenne Date: Thu, 24 Oct 2019 13:30:04 +0200 Subject: [PATCH] more tweaks --- app/DD_Clipboard_Searcher/ClassInit.vb | 4 +- .../ctrlApplicationAssignment.vb | 5 ++- .../frmControlCapture.vb | 37 +++++++++---------- .../frmProcessCapture.Designer.vb | 20 +++++----- .../frmProcessCapture.vb | 35 ++++++++++++++---- 5 files changed, 62 insertions(+), 39 deletions(-) diff --git a/app/DD_Clipboard_Searcher/ClassInit.vb b/app/DD_Clipboard_Searcher/ClassInit.vb index 357b333..4305797 100644 --- a/app/DD_Clipboard_Searcher/ClassInit.vb +++ b/app/DD_Clipboard_Searcher/ClassInit.vb @@ -239,8 +239,8 @@ Public Class ClassInit Dim ProfileSQL As String = $"SELECT DISTINCT GUID, NAME,REGEX_EXPRESSION,COMMENT,PROC_NAME,PROFILE_TYPE FROM VWCW_USER_PROFILE T1 WHERE {oWhereClause}" Dim oProcessSQL As String = $"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 ({oWhereClause})" - Dim oWindowSQL As String = $"SELECT DISTINCT * FROM VWCW_PROFILE_REL_WINDOW T, VWCW_USER_PROFILE T1 WHERE T.PROFILE_ID = T1.GUID AND ({oWhereClause})" - Dim oControlSQL As String = $"SELECT DISTINCT * FROM VWCW_PROFILE_REL_CONTROL T, VWCW_USER_PROFILE T1 WHERE T.PROFILE_ID = T1.GUID AND ({oWhereClause})" + Dim oWindowSQL As String = $"SELECT DISTINCT T.* FROM VWCW_PROFILE_REL_WINDOW T, VWCW_USER_PROFILE T1 WHERE T.PROFILE_ID = T1.GUID AND ({oWhereClause})" + Dim oControlSQL As String = $"SELECT DISTINCT T.* FROM VWCW_PROFILE_REL_CONTROL T, VWCW_USER_PROFILE T1 WHERE T.PROFILE_ID = T1.GUID AND ({oWhereClause})" Try DT_USER_PROFILES = Database.GetDatatable(ProfileSQL) diff --git a/app/DD_Clipboard_Searcher/ctrlApplicationAssignment.vb b/app/DD_Clipboard_Searcher/ctrlApplicationAssignment.vb index df12afa..2f963fe 100644 --- a/app/DD_Clipboard_Searcher/ctrlApplicationAssignment.vb +++ b/app/DD_Clipboard_Searcher/ctrlApplicationAssignment.vb @@ -116,7 +116,10 @@ Public Class ctrlApplicationAssignment End Sub Public Function Window_CreateAssignment(ProfileId As Integer) As Boolean - Dim oForm As New frmProcessCapture() + Dim oRow = GridViewProcessProfile.GetDataRow(GridViewProcessProfile.FocusedRowHandle) + Dim oCurrentProcess = oRow.Item("PROC_NAME") + + Dim oForm As New frmProcessCapture(oCurrentProcess) Dim oResult = oForm.ShowDialog() If oResult = DialogResult.OK Then diff --git a/app/DD_Clipboard_Searcher/frmControlCapture.vb b/app/DD_Clipboard_Searcher/frmControlCapture.vb index e11879f..af820cd 100644 --- a/app/DD_Clipboard_Searcher/frmControlCapture.vb +++ b/app/DD_Clipboard_Searcher/frmControlCapture.vb @@ -55,13 +55,9 @@ Public Class frmControlCapture txtControlName.Text = oControl.ControlName ControlName = oControl.ControlName End If - - Catch ex As Exception Logger.Error(ex) MsgBox($"Control Name konnte nicht ausgelesen werden!{vbNewLine}Dies kann ein temporärer Fehler sein. Bitte versuchen Sie es noch einmal.", MsgBoxStyle.Exclamation, Text) - Finally - Logger.EndBlock() End Try Try @@ -96,9 +92,9 @@ Public Class frmControlCapture Catch ex As Exception Logger.Error(ex) MsgBox($"Control Koordinaten konnten nicht ausgelesen werden!{vbNewLine}Dies kann ein temporärer Fehler sein. Bitte versuchen Sie es noch einmal.", MsgBoxStyle.Exclamation, Text) - Finally - Logger.EndBlock() End Try + + UpdateOKButton() End Sub Public Shared Function GetBoundsString(TopLeft As RectangleInfo, TopRight As RectangleInfo, BottomLeft As RectangleInfo, BottomRight As RectangleInfo) @@ -120,27 +116,30 @@ Public Class frmControlCapture Return oResult End Function + Private Sub UpdateOKButton() + If rbControlName.Checked Then + txtControlName.Enabled = rbControlName.Checked + txtControlBounds.Enabled = Not rbControlName.Checked - Private Sub RadioButton1_CheckedChanged(sender As Object, e As EventArgs) Handles rbControlName.CheckedChanged - txtControlName.Enabled = rbControlName.Checked - txtControlBounds.Enabled = Not rbControlName.Checked + btnOK.Enabled = rbControlName.Checked And ControlName <> String.Empty + ElseIf rbControlPosition.Checked Then + txtControlBounds.Enabled = rbControlPosition.Checked + txtControlName.Enabled = Not rbControlPosition.Checked - btnOK.Enabled = rbControlName.Checked And ControlName <> String.Empty + btnOK.Enabled = rbControlPosition.Checked And TopLeft IsNot Nothing + End If End Sub - Private Sub RadioButton2_CheckedChanged(sender As Object, e As EventArgs) Handles rbControlPosition.CheckedChanged - txtControlBounds.Enabled = rbControlPosition.Checked - txtControlName.Enabled = Not rbControlPosition.Checked - btnOK.Enabled = rbControlPosition.Checked And TopLeft IsNot Nothing + Private Sub RadioButton1_CheckedChanged(sender As Object, e As EventArgs) Handles rbControlName.CheckedChanged + UpdateOKButton() End Sub - Private Sub Button1_Click(sender As Object, e As EventArgs) Handles btnOK.Click - If txtControlName.Text = String.Empty And txtControlBounds.Text = String.Empty Then - MsgBox("Kein Control gefunden!") - DialogResult = DialogResult.Cancel - End If + Private Sub RadioButton2_CheckedChanged(sender As Object, e As EventArgs) Handles rbControlPosition.CheckedChanged + UpdateOKButton() + End Sub + Private Sub Button1_Click(sender As Object, e As EventArgs) Handles btnOK.Click If rbControlPosition.Checked Then ControlName = String.Empty ElseIf rbControlName.Checked Then diff --git a/app/DD_Clipboard_Searcher/frmProcessCapture.Designer.vb b/app/DD_Clipboard_Searcher/frmProcessCapture.Designer.vb index ed1a69d..a151313 100644 --- a/app/DD_Clipboard_Searcher/frmProcessCapture.Designer.vb +++ b/app/DD_Clipboard_Searcher/frmProcessCapture.Designer.vb @@ -42,7 +42,7 @@ Partial Class frmProcessCapture Me.txtPID.Location = New System.Drawing.Point(132, 4) Me.txtPID.Name = "txtPID" Me.txtPID.ReadOnly = True - Me.txtPID.Size = New System.Drawing.Size(224, 21) + Me.txtPID.Size = New System.Drawing.Size(218, 21) Me.txtPID.TabIndex = 1 ' 'txtName @@ -51,14 +51,14 @@ Partial Class frmProcessCapture Me.txtName.Location = New System.Drawing.Point(132, 32) Me.txtName.Name = "txtName" Me.txtName.ReadOnly = True - Me.txtName.Size = New System.Drawing.Size(224, 21) + Me.txtName.Size = New System.Drawing.Size(218, 21) Me.txtName.TabIndex = 2 ' 'Label1 ' Me.Label1.AutoSize = True Me.Label1.Font = New System.Drawing.Font("Tahoma", 8.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) - Me.Label1.Location = New System.Drawing.Point(12, 9) + Me.Label1.Location = New System.Drawing.Point(9, 7) Me.Label1.Name = "Label1" Me.Label1.Size = New System.Drawing.Size(62, 13) Me.Label1.TabIndex = 3 @@ -68,7 +68,7 @@ Partial Class frmProcessCapture ' Me.Label2.AutoSize = True Me.Label2.Font = New System.Drawing.Font("Tahoma", 8.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) - Me.Label2.Location = New System.Drawing.Point(12, 35) + Me.Label2.Location = New System.Drawing.Point(9, 35) Me.Label2.Name = "Label2" Me.Label2.Size = New System.Drawing.Size(78, 13) Me.Label2.TabIndex = 3 @@ -76,10 +76,10 @@ Partial Class frmProcessCapture ' 'Label3 ' - Me.Label3.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, CType((System.Drawing.FontStyle.Bold Or System.Drawing.FontStyle.Italic), System.Drawing.FontStyle), System.Drawing.GraphicsUnit.Point, CType(0, Byte)) + Me.Label3.Font = New System.Drawing.Font("Tahoma", 9.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.Label3.Location = New System.Drawing.Point(12, 98) Me.Label3.Name = "Label3" - Me.Label3.Size = New System.Drawing.Size(344, 42) + Me.Label3.Size = New System.Drawing.Size(338, 42) Me.Label3.TabIndex = 4 Me.Label3.Text = "Auswertung von aktivem Fenster läuft! Wechseln Sie durch die aktiven Anwendungen!" & "" @@ -94,14 +94,14 @@ Partial Class frmProcessCapture Me.txtWindowTitle.Location = New System.Drawing.Point(132, 58) Me.txtWindowTitle.Name = "txtWindowTitle" Me.txtWindowTitle.ReadOnly = True - Me.txtWindowTitle.Size = New System.Drawing.Size(224, 21) + Me.txtWindowTitle.Size = New System.Drawing.Size(218, 21) Me.txtWindowTitle.TabIndex = 2 ' 'Label4 ' Me.Label4.AutoSize = True Me.Label4.Font = New System.Drawing.Font("Tahoma", 8.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) - Me.Label4.Location = New System.Drawing.Point(12, 61) + Me.Label4.Location = New System.Drawing.Point(9, 61) Me.Label4.Name = "Label4" Me.Label4.Size = New System.Drawing.Size(71, 13) Me.Label4.TabIndex = 3 @@ -112,7 +112,7 @@ Partial Class frmProcessCapture Me.Button2.DialogResult = System.Windows.Forms.DialogResult.Cancel Me.Button2.Image = Global.DD_Clipboard_Watcher.My.Resources.Resources.cancel Me.Button2.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft - Me.Button2.Location = New System.Drawing.Point(197, 155) + Me.Button2.Location = New System.Drawing.Point(191, 153) Me.Button2.Name = "Button2" Me.Button2.Size = New System.Drawing.Size(159, 34) Me.Button2.TabIndex = 0 @@ -125,7 +125,7 @@ Partial Class frmProcessCapture Me.Button1.Enabled = False Me.Button1.Image = Global.DD_Clipboard_Watcher.My.Resources.Resources.add Me.Button1.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft - Me.Button1.Location = New System.Drawing.Point(18, 155) + Me.Button1.Location = New System.Drawing.Point(12, 153) Me.Button1.Name = "Button1" Me.Button1.Size = New System.Drawing.Size(159, 34) Me.Button1.TabIndex = 0 diff --git a/app/DD_Clipboard_Searcher/frmProcessCapture.vb b/app/DD_Clipboard_Searcher/frmProcessCapture.vb index 2670d0f..eb967e2 100644 --- a/app/DD_Clipboard_Searcher/frmProcessCapture.vb +++ b/app/DD_Clipboard_Searcher/frmProcessCapture.vb @@ -5,6 +5,21 @@ Public Class frmProcessCapture Public ProcessName As String Public WindowTitle As String + Private _CurrentProcess As String = String.Empty + + Public Sub New() + ' Dieser Aufruf ist für den Designer erforderlich. + InitializeComponent() + End Sub + + Public Sub New(CurrentProcess As String) + ' Dieser Aufruf ist für den Designer erforderlich. + InitializeComponent() + + ' Fügen Sie Initialisierungen nach dem InitializeComponent()-Aufruf hinzu. + _CurrentProcess = CurrentProcess + End Sub + Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick Dim oWindow = ClassWindowAPI.GetWindowInfo() @@ -13,16 +28,22 @@ Public Class frmProcessCapture End If Dim oProgramName As String = Assembly.GetEntryAssembly().GetName().Name + Dim oIsClipboardWatcherWindow = oWindow.ProcessName <> oProgramName + Dim oIsCorrectProcessName = IIf(_CurrentProcess = String.Empty, True, oWindow.ProcessName = _CurrentProcess) - If oWindow.ProcessName <> oProgramName Then - txtPID.Text = oWindow.ProcessId - txtName.Text = oWindow.ProcessName - txtWindowTitle.Text = oWindow.WindowTitle - ProcessId = oWindow.ProcessId - ProcessName = oWindow.ProcessName - WindowTitle = oWindow.WindowTitle + txtPID.Text = oWindow.ProcessId + txtName.Text = oWindow.ProcessName + txtWindowTitle.Text = oWindow.WindowTitle + ProcessId = oWindow.ProcessId + ProcessName = oWindow.ProcessName + WindowTitle = oWindow.WindowTitle + If oIsClipboardWatcherWindow And oIsCorrectProcessName Then Button1.Enabled = True + txtName.BackColor = SystemColors.Control + Else + Button1.Enabled = False + txtName.BackColor = Color.LightSalmon End If End Sub