yinkaisheng / Python-UIAutomation-for-Windows

🐍Python 3 wrapper of Microsoft UIAutomation. Support UIAutomation for MFC, WindowsForm, WPF, Modern UI(Metro UI), Qt, IE, Firefox, Chrome ...
Apache License 2.0
2.31k stars 462 forks source link

无法捕获右键菜单点击内容值 #249

Closed Della-Z closed 1 year ago

Della-Z commented 1 year ago

我的需求:结合鼠标事件捕获当前点击控件的名称和类型信息

我的实现: CursorItems = uiautomation.ControlFromCursor() LegacyIAccessiblePattern = CursorItems.GetLegacyIAccessiblePattern() print(LegacyIAccessiblePattern.Name,CursorItems.LocalizedControlType)

问题现象: 1.通过以上代码当我访问windows资源管理器右键文件选择菜单属性输出正常,即打印(“属性”,“菜单项目”) 2.当我验证相同的代码在xftp工具(当前发现的问题)右键任意文件->菜单->属性上的输出时打印为空,即LegacyIAccessiblePattern 为None 3.当我打开microsoft的Accessibility Insights工具后重复第2个操作时,右键任意文件菜单选择一项时输出正常,即打印(“属性”,“菜单项目”)

基于以上现象我想知道是否在Accessibility Insights是否对UI元素有缓存或刷新的原因? uiautomation是否可以实现该效果?

Della-Z commented 1 year ago

已通过自建缓存解决该问题