如何从 CurrentControlType 属性知道 UI 元素的 ControlType [英] How to know the ControlType of a UI Element from CurrentControlType property

查看:25
本文介绍了如何从 CurrentControlType 属性知道 UI 元素的 ControlType的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

基本上,我将 UIAutomationClient.Interop.dll 用于我目前正在做的一些 UI 工作,但我面临以下问题:

Basically I am using UIAutomationClient.Interop.dll for some UI work I am currently doing and I am facing the following issue:

  • 我有一个 UI 元素,我想知道它的控件类型.
  • UIAutomationClient.Interop.dll 公开以下属性:IUIAutomationElement::CurrentControlType 属性
  • Above 属性返回一个表示控件类型 ID 但不是 ControlType 对象的 Int.

问题:

  • 如何仅通过知道其 ID 就知道 UI 元素的 ControlType 是什么?我无法找到任何其他有用的信息.

注意:

我使用 UIAutomationTypes.dll 来定义 ControlType 对象

I am using the UIAutomationTypes.dll to definte the ControlType object

有什么想法吗?

推荐答案

我在 IronPython 中使用 GetCurrentPropertyValue(AutomationElement.ControlTypeProperty).可能这就是你想要的.它应该返回 ControlType 对象.虽然我使用它的字符串表示 .ProgrammaticName.lstrip('ControlType.').strip("'").

I use GetCurrentPropertyValue(AutomationElement.ControlTypeProperty) in IronPython. Probably this is what you want. It should return ControlType object. Though I use its string representation .ProgrammaticName.lstrip('ControlType.').strip("'").

这篇关于如何从 CurrentControlType 属性知道 UI 元素的 ControlType的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆