118 lines
3.8 KiB
VB.net
118 lines
3.8 KiB
VB.net
Imports DigitalData.Modules.Windows
|
|
Imports DigitalData.Modules.Windows.Window
|
|
|
|
Public Class frmControlCapture
|
|
Public Property TopLeft As RectangleInfo
|
|
Public Property TopRight As RectangleInfo
|
|
Public Property BottomLeft As RectangleInfo
|
|
Public Property BottomRight As RectangleInfo
|
|
|
|
Public Property ControlName As String
|
|
|
|
Private WithEvents Watcher As ClipboardWatcher = ClipboardWatcher.Singleton
|
|
Private Window As Window
|
|
|
|
Private EditMode As Boolean = False
|
|
|
|
Public Sub New(EditMode As Boolean)
|
|
' Dieser Aufruf ist für den Designer erforderlich.
|
|
InitializeComponent()
|
|
|
|
' Fügen Sie Initialisierungen nach dem InitializeComponent()-Aufruf hinzu.
|
|
EditMode = EditMode
|
|
End Sub
|
|
|
|
Private Sub frmControlCapture_Load(sender As Object, e As EventArgs) Handles Me.Load
|
|
Window = New Window(LogConfig)
|
|
|
|
rbControlName.Checked = True
|
|
|
|
AddHandler Watcher.Changed, AddressOf Watcher_Changed
|
|
End Sub
|
|
|
|
Private Sub Watcher_Changed(sender As Object, e As EventArgs)
|
|
' === CONTROL NAME ===
|
|
|
|
Dim oControl As WindowInfo = Window.GetFocusedControl(Handle)
|
|
|
|
If oControl IsNot Nothing Then
|
|
TextBox1.Text = oControl.ControlName
|
|
ControlName = oControl.ControlName
|
|
End If
|
|
|
|
' === CONTROL POSITION ===
|
|
|
|
For Each oAnchor As Anchor In [Enum].GetValues(GetType(Anchor))
|
|
Dim oRect As RectangleInfo = Window.GetFocusedControlLocation(Handle, oAnchor)
|
|
|
|
Select Case oAnchor
|
|
Case Window.Anchor.TopLeft
|
|
If oRect IsNot Nothing Then
|
|
TopLeft = oRect
|
|
End If
|
|
|
|
Case Window.Anchor.TopRight
|
|
If oRect IsNot Nothing Then
|
|
TopRight = oRect
|
|
End If
|
|
|
|
Case Window.Anchor.BottomLeft
|
|
If oRect IsNot Nothing Then
|
|
BottomLeft = oRect
|
|
End If
|
|
|
|
Case Window.Anchor.BottomRight
|
|
If oRect IsNot Nothing Then
|
|
BottomRight = oRect
|
|
End If
|
|
End Select
|
|
|
|
TextBox2.Text = GetBoundsString()
|
|
Next
|
|
End Sub
|
|
|
|
Private Function GetBoundsString()
|
|
Dim oResult As String = String.Empty
|
|
|
|
If TopLeft IsNot Nothing Then
|
|
oResult &= TopLeft.ToString & vbNewLine
|
|
End If
|
|
If TopRight IsNot Nothing Then
|
|
oResult &= TopRight.ToString & vbNewLine
|
|
End If
|
|
If BottomLeft IsNot Nothing Then
|
|
oResult &= BottomLeft.ToString & vbNewLine
|
|
End If
|
|
If BottomRight IsNot Nothing Then
|
|
oResult &= BottomRight.ToString & vbNewLine
|
|
End If
|
|
|
|
Return oResult
|
|
End Function
|
|
|
|
Private Sub RadioButton1_CheckedChanged(sender As Object, e As EventArgs) Handles rbControlName.CheckedChanged
|
|
gbControlName.Enabled = rbControlName.Checked
|
|
gbControlPosition.Enabled = Not rbControlName.Checked
|
|
End Sub
|
|
|
|
Private Sub RadioButton2_CheckedChanged(sender As Object, e As EventArgs) Handles rbControlPosition.CheckedChanged
|
|
gbControlName.Enabled = Not rbControlPosition.Checked
|
|
gbControlPosition.Enabled = rbControlPosition.Checked
|
|
End Sub
|
|
|
|
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
|
|
If TextBox1.Text = String.Empty And TextBox2.Text = String.Empty Then
|
|
MsgBox("Kein Control gefunden!")
|
|
DialogResult = DialogResult.Cancel
|
|
End If
|
|
|
|
If rbControlPosition.Checked Then
|
|
ControlName = String.Empty
|
|
Else
|
|
TopLeft = New RectangleInfo()
|
|
TopRight = New RectangleInfo()
|
|
BottomLeft = New RectangleInfo()
|
|
BottomRight = New RectangleInfo()
|
|
End If
|
|
End Sub
|
|
End Class |