75 lines
2.8 KiB
VB.net
75 lines
2.8 KiB
VB.net
Imports System.Windows.Automation
|
|
Imports DD_Clipboard_Watcher.ClassWindowAPI
|
|
|
|
Public Class frmControlCapture
|
|
Public ControlName As String
|
|
Public ProcessName As String
|
|
Public AutomationId As String
|
|
Public FrameworkId As String
|
|
|
|
Public Automation As ClassAutomation
|
|
|
|
Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
|
|
Dim oResult As WindowInfo = GetFocusedControl(Handle)
|
|
Dim newoResult As IntPtr = FocusedControlinActiveWindow(Handle)
|
|
|
|
If oResult IsNot Nothing Then
|
|
txtPID.Text = oResult.ClassName
|
|
txtName.Text = oResult.ProcessName
|
|
txtControlName.Text = oResult.ControlName
|
|
txtAutomationId.Text = Automation.AutomationId
|
|
txtFrameworkId.Text = Automation.FrameworkId
|
|
Console.WriteLine($"Automation.AutomationId: {Automation.AutomationId}")
|
|
FrameworkId = Automation.FrameworkId
|
|
|
|
ControlName = oResult.ControlName
|
|
Console.WriteLine($"oResult.ControlName: {oResult.ControlName}")
|
|
txtNewFocusControlHandle.Text = newoResult.ToString
|
|
AutomationId = newoResult.ToString
|
|
Console.WriteLine($"newoResult: {newoResult.ToString}")
|
|
|
|
ProcessName = oResult.ProcessName
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub frmControlCapture_Load(sender As Object, e As EventArgs) Handles MyBase.Load
|
|
Automation = New ClassAutomation(LogConfig)
|
|
End Sub
|
|
|
|
Private Sub frmControlCapture_FormClosing(sender As Object, e As FormClosingEventArgs) Handles Me.FormClosing
|
|
Timer1.Stop()
|
|
Automation.RemoveHandler()
|
|
End Sub
|
|
|
|
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
|
|
If chkAutomationId.Checked = False Then
|
|
AutomationId = String.Empty
|
|
End If
|
|
|
|
If chkControlName.Checked = False Then
|
|
ControlName = String.Empty
|
|
End If
|
|
|
|
If chkAutomationId.Checked = False And chkControlName.Checked = False Then
|
|
MsgBox("Es muss entweder die AutomationId oder der Feldname ausgewählt sein!", MsgBoxStyle.Exclamation, Text)
|
|
DialogResult = DialogResult.None
|
|
End If
|
|
Timer1.Stop()
|
|
End Sub
|
|
|
|
Private Sub chkControlName_CheckedChanged(sender As Object, e As EventArgs) Handles chkControlName.CheckedChanged
|
|
If chkControlName.Checked Then
|
|
chkAutomationId.Checked = False
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub chkAutomationId_CheckedChanged(sender As Object, e As EventArgs) Handles chkAutomationId.CheckedChanged
|
|
If chkAutomationId.Checked Then
|
|
chkControlName.Checked = False
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
|
|
Timer1.Stop()
|
|
End Sub
|
|
End Class |