C#通过UI Automation 获取QQ聊天窗口的聊天记录的疑问

qq_29791765 2017-03-27 05:08:09
如图所示,通过inspect.exe可以找的到QQ聊天记录,

1:聊天窗口消息区,AutomationElement的Name值为“消息”;
2:此处是聊天记录内容。
C#程序中可找到外层聊天窗口的AutomationElement对象,但通过该对象找不到消息区


AutomationElement aeTop = AutomationElement.RootElement; //找到桌面根元素
AutomationElement aeForm = aeTop.FindFirst(TreeScope.Children, new PropertyCondition(AutomationElement.NameProperty, "XXXX交流群")); //找到XXXX交流群的聊天窗口
AutomationElement aeMessage= aeForm .FindFirst(TreeScope.Descendants, new PropertyCondition(AutomationElement.NameProperty, "消息")); //找不到消息区,aeMessage值为空

通过AutomationElement的两个静态方法(1.通过指定点找到AutomationElement;2.通过当前获得焦点找到AutomationElement)也不能获取到消息区的AutomationElement对象,结果获得了聊天窗口的AutomationElement对象
注:两个方法的指定点和当前焦点都已经指向消息区位置了。

AutomationElement focusedElement = AutomationElement.FocusedElement; //获取当前焦点AutomationElement元素
AutomationElement pointElement= AutomationElement.FromPoint(new System.Windows.Point(868, 346)); //获取指定点处AutomationElement元素

本人认为应该是TX对其做了保护限制,不知道该如何解决 。有没有做过类似开发的大神指点一下小弟。
...全文
1813 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
慧眼识狗熊 2017-09-04
  • 打赏
  • 举报
回复
激活窗体,模拟按键tab,定位到消息区,模拟按键全选,复制,搞定。
cyg17173 2017-09-04
  • 打赏
  • 举报
回复
马克,好感兴趣的话题,大神们多指点下。
weixin_39532039 2017-09-03
  • 打赏
  • 举报
回复
引用 2 楼 stherix 的回复:
如果用IAccessable接口是可以取到qq窗口的聊天记录的 只不过只能取到整个聊天窗口的全部内容
很感兴趣,能指点下吗?
stherix 2017-03-29
  • 打赏
  • 举报
回复
如果用IAccessable接口是可以取到qq窗口的聊天记录的 只不过只能取到整个聊天窗口的全部内容
菜鸟的挣扎 2017-03-28
  • 打赏
  • 举报
回复
对象有此方法,就说明是可用的(不然写此方法是吃撑着不成?),只是用得不对罢了

111,124

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Creator Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧