ARTICLE DETAIL

建站实战干货

来自一线的建站与推广经验沉淀,每一条都经过真实交付验证。

C# 获取QQ会话聊天信息

2026/9/27 10:35:01 拓冰建站 浏览量
C# 获取QQ会话聊天信息

目录

利用UIAutomation获取QQ会话聊天信息

效果 

代码 

目前遇到一个问题

其他解决办法


利用UIAutomation获取QQ会话聊天信息

效果 

代码 

AutomationElement window = AutomationElement.FromHandle(get.WindowHwnd);

AutomationElement QQMsgList = window.FindFirst(TreeScope.Descendants,
    new PropertyCondition(AutomationElement.NameProperty, "消息"));
if (QQMsgList != null)
{
    AutomationElementCollection ALLMsg = QQMsgList.FindAll(TreeScope.Descendants,
        new PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.ListItem));

    foreach (AutomationElement item in ALLMsg)
    {
        rtxtInfo.AppendText(item.Current.Name + "\r\n");
    }
}

AutomationElement window = AutomationElement.FromHandle(get.WindowHwnd);AutomationElement QQMsgList = window.FindFirst(TreeScope.Descendants,new PropertyCondition(AutomationElement.NameProperty, "消息"));
if (QQMsgList != null)
{AutomationElementCollection ALLMsg = QQMsgList.FindAll(TreeScope.Descendants,new PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.ListItem));foreach (AutomationElement item in ALLMsg){rtxtInfo.AppendText(item.Current.Name + "\r\n");}
}

目前遇到一个问题

获取的聊天信息不全,最近的多条聊天信息获取不到。

其他解决办法

1、截图OCR识别

2、不断复制,从剪切板中读取