C#通過UI Automation 獲取QQ聊天窗口的聊天記錄


如圖所示,通過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元素

 來自於:C#通過UI Automation 獲取QQ聊天窗口的聊天記錄的疑問-CSDN社區


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM