First of all, when the program is turned on, processes appear, and among the processes, I select the process that I want to control (in this case, I get a handle value from the process).
Find all button controls in the lower part and add them to the listbox.
I want to use the invoke method or the focus method for the buttons added in order, but when I click an item in the listbox, a NullReference error occurs. What is the problem?
Also, how should i solve it?
Items added to the listbox are simply
Dim isExpandCollapsePatternAvailableProperty As Condition = New PropertyCondition(AutomationElement.IsExpandCollapsePatternAvailableProperty, True)
Dim isenablecondi As Condition = New PropertyCondition(AutomationElement.IsEnabledProperty, True)
Dim isoffcondi As Condition = New PropertyCondition(AutomationElement.IsOffscreenProperty, True)
Dim andcon As AndCondition = New AndCondition(isoffcondi, isenablecondi, isExpandCollapsePatternAvailableProperty)
Dim aec As AutomationElementCollection = GetMainControl.FindAll(TreeScope.Subtree, isenablecondi)
For Each ae As AutomationElement In aec
If ae.Current.ControlType.ProgrammaticName = "ControlType.Button" Then
ListBox1.Items.Add(ae.Current.ControlType.LocalizedControlType & ":" & ae.Current.Name)
End If
Next
It is added in this way and the use was done through TryCast. How can I actually control the buttons through the list of buttons added to the listbox?
Sorry my English, Google translator.
Example Usage: Dim AE As AutomationElement = TryCast(ListBox1.SelectedItem, AutomationElement)
ButtonInvoker(AE)
Also, it seems that the third-party program to be manipulated was developed in WPF.