1

基本的に、現在行っているいくつかの UI 作業に UIAutomationClient.Interop.dll を使用していますが、次の問題に直面しています。

  • コントロール タイプを知りたい UI 要素があります。
  • UIAutomationClient.Interop.dll は次のプロパティを公開します: IUIAutomationElement::CurrentControlType プロパティ
  • 上記のプロパティは、ControlType オブジェクトではなく、コントロール タイプ ID を表す Int を返します。

質問:

  • ID を知るだけで UI 要素の ControlType を知るにはどうすればよいでしょうか? 他に有益な情報を見つけることができませんでした。

:

UIAutomationTypes.dll を使用して ControlType オブジェクトを定義しています

何か案が?

4

2 に答える 2

0

2021年にこれを行う方法をまだ探している人向け(IUIAutomationElementを使用)。LookupById()System.Windows.Automation.ControlType クラスによって提供される関数を使用するだけです。

// 
IUIAutomationElement element;
// ...
// your code to retrieve the element you want
// ...

// the next line fixes a bug in ControlType class, as explained here: https://stackoverflow.com/a/13971182/991782
ControlType.Button.ToString();

var elementControlType = System.Windows.Automation.ControlType.LookupById(element.CurrentControlType);
于 2021-03-31T16:09:24.527 に答える