262 lines
11 KiB
VB.net
262 lines
11 KiB
VB.net
Imports System.Threading
|
|
Imports DD_LIB_Standards
|
|
Public Class frmMain
|
|
Dim WithEvents Hotkey As New clsHotkey(Me)
|
|
|
|
Private PID As Integer
|
|
Private WithEvents _Watcher As ClipboardWatcher = ClipboardWatcher.Singleton
|
|
Private Sub frmClipboardWatch_Disposed(ByVal sender As Object, _
|
|
ByVal e As EventArgs) Handles Me.Disposed
|
|
_Watcher.Dispose()
|
|
End Sub
|
|
|
|
Private Sub _Watcher_Changed(ByVal sender As Object,
|
|
ByVal e As EventArgs) Handles _Watcher.Changed
|
|
If DT_USER_PROFILES Is Nothing Then
|
|
Exit Sub
|
|
End If
|
|
If DT_USER_PROFILES.Rows.Count = 0 Then
|
|
Exit Sub
|
|
End If
|
|
CURR_MATCH_RESULT = Nothing
|
|
CURR_MATCH_WM_SEARCH = Nothing
|
|
If MONITORING_ACTIVE = False Then
|
|
NotifyIconMain.ShowBalloonTip(20000, "Clipboard Watcher", "Clipboard-watcher is inactive.", ToolTipIcon.Info)
|
|
Exit Sub
|
|
End If
|
|
|
|
Dim Data As IDataObject = Clipboard.GetDataObject
|
|
|
|
' Dim RelevantWindow = clsWINDOWSApi.IsRelevantWindow("jonathan")
|
|
'With Me.TextBox1
|
|
' .AppendText(String.Concat("Available Formats:", vbNewLine))
|
|
' .AppendText(String.Join(vbNewLine, Data.GetFormats))
|
|
' .AppendText(String.Concat(vbNewLine, vbNewLine, "Text = '", _
|
|
' Clipboard.GetText, "'", vbNewLine, vbNewLine))
|
|
'End With
|
|
Dim found As Boolean = False
|
|
CLIPBOARD_TEXT = Clipboard.GetText
|
|
If LogErrorsOnly = False Then clsLogger.Add(String.Format(" >>{0} - Clipboard-Watcher fired for process '{1}'", Now.ToString, PROC_Name), False)
|
|
|
|
For Each row As DataRow In DT_USER_PROFILES.Rows
|
|
If found = True Then Exit For
|
|
If PROC_Name.ToUpper = row.Item("PROC_NAME").ToString.ToUpper Then
|
|
Dim regex_expression = row.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
|
|
|
|
' If match.Groups(0).Value <> CURR_MATCH_RESULT Then
|
|
CURR_MATCH_RESULT = match.Groups(0).Value
|
|
If Not IsNothing(CURR_MATCH_RESULT) Then
|
|
CURR_MATCH_WM_SEARCH = row.Item("WD_SEARCH")
|
|
|
|
found = True
|
|
End If
|
|
'Else
|
|
' NotifyIconMain.ShowBalloonTip(20000, "Clipboard Watcher", String.Format("Clipboard Watcher fired but Clipboardcontent is equal: '{0}'", CURR_MATCH_RESULT), ToolTipIcon.Info)
|
|
' If LogErrorsOnly = False Then clsLogger.Add(String.Format(" >> {0} - Equal Clipboard-result '{1}'", Now.ToString, CURR_MATCH_RESULT), False)
|
|
' Exit For
|
|
'End If
|
|
Else
|
|
If LogErrorsOnly = False Then clsLogger.Add(String.Format(" >> {0} - No regex-match for cliboardtext '{1}'", Now.ToString, match.Groups(0).Value), False)
|
|
End If
|
|
End If
|
|
Next
|
|
If found = False Then
|
|
If LogErrorsOnly = False Then clsLogger.Add(String.Format(" >> {0} - Process '{1}' not configured!", Now.ToString, PROC_Name), False)
|
|
End If
|
|
|
|
End Sub
|
|
|
|
Public Sub New()
|
|
Dim splash As New frmSplash()
|
|
splash.ShowDialog()
|
|
If ERROR_INIT <> "INVALID USER" Then
|
|
Dim cultureInfo As System.Globalization.CultureInfo
|
|
cultureInfo = New System.Globalization.CultureInfo(USER_LANGUAGE)
|
|
'cultureInfo.DateTimeFormat.ShortDatePattern = USER_DATE_FORMAT
|
|
Thread.CurrentThread.CurrentCulture = cultureInfo
|
|
Thread.CurrentThread.CurrentUICulture = cultureInfo
|
|
Globalization.CultureInfo.DefaultThreadCurrentCulture = cultureInfo
|
|
Globalization.CultureInfo.DefaultThreadCurrentUICulture = cultureInfo
|
|
End If
|
|
' Dieser Aufruf ist für den Designer erforderlich.
|
|
InitializeComponent()
|
|
|
|
' Fügen Sie Initialisierungen nach dem InitializeComponent()-Aufruf hinzu.
|
|
|
|
End Sub
|
|
|
|
Private Sub btnUserConfig_Click(sender As Object, e As EventArgs) Handles btnUserConfig.Click
|
|
frmConfig_Basic.ShowDialog()
|
|
End Sub
|
|
|
|
Private Sub frmMain_FormClosing(sender As Object, e As FormClosingEventArgs) Handles Me.FormClosing
|
|
clsLogger.Add(">> Logout time: " & Now.ToString, False)
|
|
If ERROR_INIT = "INVALID USER" Then
|
|
Exit Sub
|
|
End If
|
|
Try
|
|
'Dim sql = String.Format("UPDATE TBDD_USER SET LOGGED_IN = 0, LOGGED_WHERE = '{0}' WHERE (LOWER(USERNAME) = LOWER('{1}'))", "", USER_USERNAME)
|
|
'clsDatabase.Execute_non_Query(sql, True)
|
|
Dim sql = "DELETE FROM TBDD_USER_MODULE_LOG_IN WHERE USER_ID = " & USER_GUID & " AND UPPER(MODULE) = UPPER('Clipboard-Searcher')"
|
|
clsDatabase.Execute_non_Query(sql, True)
|
|
ClassWindowLocation.SaveFormLocationSize(Me, "")
|
|
My.Settings.Save()
|
|
|
|
Catch ex As Exception
|
|
|
|
End Try
|
|
Try
|
|
Hotkey.RemoveHotKey(354522017)
|
|
Catch ex As Exception
|
|
|
|
End Try
|
|
Try
|
|
Hotkey.RemoveHotKey(354523017)
|
|
Catch ex As Exception
|
|
|
|
End Try
|
|
|
|
'TempDateien löschen
|
|
Try
|
|
For Each _file In TEMP_FILES
|
|
System.IO.File.Delete(_file)
|
|
Next
|
|
Catch ex As Exception
|
|
|
|
End Try
|
|
If clsLogger.LOGG_MSG <> String.Empty Then
|
|
clsLogger.Add(clsLogger.LOGG_MSG, False)
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub frmMain_Load(sender As Object, e As EventArgs) Handles Me.Load
|
|
ClassWindowLocation.LoadFormLocationSize(Me)
|
|
If clsDatabase.DB_DEFAULT_INITIALIZED = True Then
|
|
Me.NotifyIconMain.Visible = True
|
|
clsHotkey.Refresh_Profile_Links()
|
|
Hotkey.AddHotKey(Keys.T, clsHotkey.MODKEY.MOD_CONTROL, 354522017)
|
|
Dim keyCode As Keys
|
|
Dim kc As New KeysConverter
|
|
Dim obj As Object = kc.ConvertFromString(HotkeySearchKey.ToUpper)
|
|
keyCode = CType(obj, Keys)
|
|
If HotkeyFunctionKey = "strg" Then
|
|
Hotkey.AddHotKey(keyCode, clsHotkey.MODKEY.MOD_CONTROL, 354523017)
|
|
ElseIf HotkeyFunctionKey = "SHIFT" Then
|
|
Hotkey.AddHotKey(keyCode, clsHotkey.MODKEY.MOD_SHIFT, 354523017)
|
|
End If
|
|
|
|
End If
|
|
tslblUser.Text = USER_USERNAME
|
|
lbHKFunction.Text = HotkeyFunctionKey & " + " & HotkeySearchKey.ToUpper
|
|
End Sub
|
|
Private Sub ReceiveHotKey(ByVal HotKeyID As String) Handles Hotkey.HotKeyPressed
|
|
If HotKeyID = 354523017 Then
|
|
If Not IsNothing(CURR_MATCH_RESULT) And Not IsNothing(CURR_MATCH_WM_SEARCH) Then
|
|
clsSearch.RUN_WD_SEARCH(CURR_MATCH_WM_SEARCH)
|
|
End If
|
|
ElseIf HotKeyID = 354522017 Then
|
|
Change_Monitoring_State()
|
|
End If
|
|
|
|
End Sub
|
|
Sub Change_Monitoring_State()
|
|
If MONITORING_ACTIVE = True Then
|
|
NotifyIconMain.ShowBalloonTip(30000, "Clipboard Watcher", "Clipboard-Watcher wurde inaktiviert!", ToolTipIcon.Info)
|
|
MONITORING_ACTIVE = False
|
|
Else
|
|
MONITORING_ACTIVE = True
|
|
NotifyIconMain.ShowBalloonTip(30000, "Clipboard Watcher", "Clipboard-Watcher wurde wieder aktiviert!", ToolTipIcon.Info)
|
|
End If
|
|
End Sub
|
|
Private Sub frmMain_Shown(sender As Object, e As EventArgs) Handles Me.Shown
|
|
If ERROR_INIT <> "INVALID USER" And LICENSE_COUNT > 0 Then
|
|
If DT_USER_PROFILES.Rows.Count >= 1 Then
|
|
Me.Hide()
|
|
End If
|
|
Else
|
|
If USER_IS_ADMIN = True And ERROR_INIT = "NO LICENSE" Then
|
|
MsgBox("As an admin You have exit! Please inform Digital Data to add a valid license!", MsgBoxStyle.Exclamation, "")
|
|
Else
|
|
MsgBox("Application will close now!", MsgBoxStyle.Critical, "")
|
|
Me.Close()
|
|
End If
|
|
End If
|
|
If USER_IS_ADMIN = True Then
|
|
btnAdminConfig.Visible = True
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub NotifyIcon1_DoubleClick(sender As Object, e As EventArgs) Handles NotifyIconMain.DoubleClick
|
|
If Me.Visible = False Then
|
|
Me.BringToFront()
|
|
Me.Visible = True
|
|
TimerClose.Start()
|
|
Else
|
|
Me.Hide()
|
|
NotifyIconMain.Visible = True
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub frmMain_KeyUp(sender As Object, e As KeyEventArgs) Handles MyBase.KeyUp
|
|
If e.KeyCode = Keys.F12 And USER_IS_ADMIN = True Then
|
|
frmLicense.ShowDialog()
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub tsmiChangeState_Click(sender As Object, e As EventArgs) Handles tsmiChangeState.Click
|
|
If tsmiChangeState.Tag = "stop" Then
|
|
tsmiChangeState.Tag = "start"
|
|
tsmiChangeState.Image = My.Resources.control_start_blue
|
|
tsmiChangeState.Text = "Überwachung Clipboard starten"
|
|
MONITORING_ACTIVE = False
|
|
NotifyIconMain.ShowBalloonTip(30000, "Clipboard Watcher", "Clipboard-Watcher wurde inaktiviert!", ToolTipIcon.Info)
|
|
Else
|
|
tsmiChangeState.Image = My.Resources.StatusAnnotations_Stop_16xLG
|
|
tsmiChangeState.Tag = "stop"
|
|
tsmiChangeState.Text = "Überwachung Clipboard stoppen"
|
|
MONITORING_ACTIVE = True
|
|
NotifyIconMain.ShowBalloonTip(30000, "Clipboard Watcher", "Clipboard-Watcher wurde wieder aktiviert!", ToolTipIcon.Info)
|
|
End If
|
|
End Sub
|
|
'Private Sub Timer1_Tick(sender As Object, e As EventArgs)
|
|
' clsWINDOWSApi.Get_ForegroundWindow_Info()
|
|
' If PID <> PROC_PID Then
|
|
' PID = PROC_PID
|
|
' With Me.TextBox1
|
|
' .AppendText(String.Concat("Process-ID:" & PROC_PID, vbNewLine))
|
|
' .AppendText(String.Concat("Process-Name:" & PROC_Name, vbNewLine))
|
|
' .AppendText("Window-Title: " & PROC_WindowTitle)
|
|
' .AppendText(String.Concat("", vbNewLine))
|
|
' End With
|
|
' End If
|
|
|
|
'End Sub
|
|
|
|
Private Sub btnAdminConfig_Click(sender As Object, e As EventArgs) Handles btnAdminConfig.Click
|
|
TimerClose.Stop()
|
|
MONITORING_ACTIVE = False
|
|
frmAdministration.ShowDialog()
|
|
TimerClose.Start()
|
|
MONITORING_ACTIVE = True
|
|
End Sub
|
|
|
|
Private Sub TimerClose_Tick(sender As Object, e As EventArgs) Handles TimerClose.Tick
|
|
Me.Hide()
|
|
End Sub
|
|
|
|
Private Sub frmMain_VisibleChanged(sender As Object, e As EventArgs) Handles Me.VisibleChanged
|
|
If TimerClose.Enabled = True Then
|
|
TimerClose.Stop()
|
|
End If
|
|
|
|
End Sub
|
|
|
|
Private Sub MinimierenToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles MinimierenToolStripMenuItem.Click
|
|
Me.Hide()
|
|
End Sub
|
|
|
|
End Class
|