ツールバー付きの ActiveX コントロール (Adobe PDF Reader) があります。このコントロールは、ツールバーから使用できる一部の機能 (主に検索機能) を公開しません。プログラムでツールバーの検索フィールドを見つけ、テキストを入力して検索を呼び出す方法を探しています (このフィールドで Enter キーを押すのと同じです)。それを行う最も正確な方法は何ですか?System.Windows.Automation 名前空間に基づくソリューションが見つかりましたが、正しく動作させることができませんでした。
ありがとう。
私が試したコードは次のとおりです。
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