用C#能在QQ窗体里发送消息吗?

wangtiantian23 wangtiantian23 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
查了好多文章都无法完美解决在QQ窗体里发送消息。但是看有些桌面应用是可以给在QQ窗体里发送消息的。
看到有用AumotaionElement方式实现,我也尝试写了一下,能发现窗体但是无法找到文本框和发送消息。


AutomationElement aeDeskTop = AutomationElement.RootElement;

// 不设定查找条件,列出所有窗体
this.textBox1.AppendText("\r\n");
AutomationElementCollection elementCollection = aeDeskTop.FindAll(TreeScope.Children, Condition.TrueCondition);
foreach (AutomationElement frm in elementCollection)
{
this.textBox1.AppendText(string.Format("窗体名称:{0}\r\n", frm.Current.Name));
if (frm.Current.Name == "豆干") //这里是打开的QQ窗体的名称
{
elementCollection = frm.FindAll(TreeScope.Subtree,
Condition.TrueCondition);
foreach (AutomationElement control in elementCollection)
{
this.textBox1.AppendText(string.Format("控件id:{0}\r\n", control.Current.AutomationId));
}
}
}


用以上代码能找到窗体,但是无法找到里面的文本框和按钮

//从网上找到的输入文本内容
System.Windows.Forms.SendKeys.SendWait(textBox2.Text);

//从网上找到的点击发送消息按钮
InvokePattern ipClickButton1 = (InvokePattern)aeAllEdit1[t].GetCurrentPattern(InvokePattern.Pattern);
ipClickButton1.Invoke();
//这两步都无法实现


有什么好方法能实现那???请各位大神不吝赐教。
...全文
评论 6
收藏 已收藏
分享
返回顶部
wangtiantian23
C# 111,128 成员 642,536 内容