I have an ActiveX control (Adobe PDF Reader) with a toolbar. This control doesn't expose some functions available through toolbar (mainly search function). I'm looking for a way to programmatically locate Search field on the toolbar, enter the text and invoke search (equivalent of pressing Enter in this field). What's most accurate way to make that? Found a solution based on System.Windows.Automation namespace, but couldn't get it to work correctly.
Thanks.
Here's the code I tried:
Dim pdfElement As AutomationElement = AutomationElement.FromHandle(AxAcroPDF1.Handle)
Dim condition As New AndCondition(New OrCondition(New PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.Edit), New PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.Document), New PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.Text)), New PropertyCondition(AutomationElement.IsTextPatternAvailableProperty, True))
Dim ac As AutomationElementCollection = pdfElement.FindAll(TreeScope.Descendants, condition)
For Each element As AutomationElement In ac
If element.Current.Name = "Find" Then
element.SetFocus()
SendKeys.Send("TESTSEARCH")
End If
Next