java qq协议 c#,C#模拟手机QQ发送QQ消息[QQhttp1-4协议].doc

C#模拟手机QQ发送QQ消息[QQhttp1-4协议].doc

HYPERLINK "/caodavid2003/article/details C#模拟手机QQ 发送QQ消息(QQhttp1.4协议)详细代码如下(代码参考网上他人代码修改的,不完全相同):private void button1_Click(object sender, EventArgs e) { //string SEQ = DateTime.Now.Ticks.ToString().Substring(7, 7); string QqNum = "1319333759";//用来发送QQ消息的QQ string QqPwd = "413C570DDD92A9983C8FECEB7385594D";//MD5加密413c570ddd92a9983c8feceb7385594d string Msg = "测试QQ发送消息"; string strLogin = "VER=1.4&CON=1&CMD=Login&SEQ=" + GetSjs3Byte() + "&UIN=" + QqNum + "&PS=" + QqPwd + "&M5=1&LG=0&LC=812822641C978097&GD=TW00QOJ9KUVD753S&CKE=\n"; Console.WriteLine("登录状况:" + Post(strLogin)); string receiveQQ="709334572";//接收消息的QQ,注意这个QQ需要与发送消息的QQ是好友关系,否则发送接收不到的。 string strMsg = "VER=1.4&CON=1&CMD=CLTMSG&SEQ=" + GetSjs3Byte() + "&UIN=" + QqNum + "&SID=&XP=C4CA4238A0B92382&UN=" +receiveQQ+"&MG=" + Msg; Console.WriteLine("发送消息结果:" + Post(strMsg)); } /// /// 获取200到299的随机数 /// /// public string GetSjs3Byte() { Random rnd = new Random(); int i = rnd.Next(200, 999); return i.ToString(); } public static string Post(string postValues) { string Host = "53:14000"; WebClient _client = new WebClient(); Byte[] byteArray = System.Text.Encoding.UTF8.GetBytes(postValues); Byte[] pageData = _client.UploadData(Host, "POST", byteArray); string returnVal = Encoding.UTF8.GetString(pageData); return returnVal; }

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
作者: 三角猫 出处: http://www.zu14.cn/ 版权归 三角猫 和 真有意思网 所有,转载请注明出处 using System; using System.Collections.Generic; using System.Text; namespace QQAutoMsg { /// /// 消息发送 /// internal static class QQMsgSender { /// /// 发送消息 /// /// 所以已打开的QQ窗体的列表 /// 消息内容 internal static void Go(List qqChatWindows, string msg) { foreach (EnumQQChatWindows.QQChatWindow win in qqChatWindows) { SendMsg(win.WindowHwnd, msg); } } /// /// 根据窗体句柄,找到输入框和发送按钮,发送消息出去 /// /// 聊天窗口句柄 /// 消息内容 private static void SendMsg(IntPtr hWnd, string msg) { if (NativeMethods.IsWindow(hWnd)) //确认该聊天窗口仍然有效 { ////找到 发送 按钮 IntPtr hwndButton = NativeMethods.FindWindowEx(hWnd, IntPtr.Zero, "Button", "发送(S)"); if (IntPtr.Zero != hwndButton) { ////找到窗体顺序上的第一个RichEdit20A控件,其实就是消息显示框 IntPtr hwndRichEdit = NativeMethods.FindWindowEx(hWnd, IntPtr.Zero, "RichEdit20A", null); ////利用spy++,可以看到消息输入框的父窗体是类名为 AfxWnd42 的控件 ////在顺序上是显示框的下一个窗体 if (IntPtr.Zero != hwndRichEdit) { ////找到 AfxWnd42 这个窗体 hwndRichEdit = NativeMethods.GetWindow(hwndRichEdit, NativeMethods.GW_HWNDNEXT); if (IntPtr.Zero != hwndRichEdit) { ////这才是真正的消息输入框 hwndRichEdit = NativeMethods.FindWindowEx(hwndRichEdit, IntPtr.Zero, "RichEdit20A", null); if (hwndRichEdit != IntPtr.Zero) { ////发送消息,因为QQ屏蔽了 WM_SETTEXT, WM_PASTE 命令,所有采用 EM_REPLACESEL 来实现 NativeMethods.SendMessage(hwndRichEdit, NativeMethods.EM_REPLACESEL, IntPtr.Zero, msg); ////给发送按钮发 鼠标单击消息 NativeMethods.SendMessage(hwndButton, NativeMethods.BM_CLICK, IntPtr.Zero, IntPtr.Zero); } } } } } } } }

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值