1090 lines
37 KiB
C#
1090 lines
37 KiB
C#
/*
|
||
* 由SharpDevelop创建。
|
||
* 用户: Administrator
|
||
* 日期: 2019/6/4 星期二
|
||
* 时间: 09:50
|
||
*
|
||
* 要改变这种模板请点击 工具|选项|代码编写|编辑标准头文件
|
||
*/
|
||
using System;
|
||
using System.Collections.Generic;
|
||
using System.Drawing;
|
||
using System.Windows.Forms;
|
||
using System.Runtime.InteropServices;
|
||
using System.Diagnostics;
|
||
using System.Text;
|
||
using Newtonsoft.Json;
|
||
using Newtonsoft.Json.Linq;
|
||
using System.IO;
|
||
using System.Net;
|
||
using System.Resources;
|
||
using System.Reflection;
|
||
namespace WxRobot
|
||
{
|
||
/// <summary>
|
||
/// Description of MainForm.
|
||
/// </summary>
|
||
public partial class MainForm : Form
|
||
{
|
||
private static readonly object SequenceLock = new object();
|
||
|
||
WeChatAPI wxAPI = new WeChatAPI();
|
||
|
||
public MainForm()
|
||
{
|
||
//
|
||
// The InitializeComponent() call is required for Windows Forms designer support.
|
||
//
|
||
InitializeComponent();
|
||
|
||
Control.CheckForIllegalCrossThreadCalls = false;
|
||
|
||
byte[] bytPath = new byte[260];
|
||
int i = KstAPI.kst_GetPath(ref bytPath[0]);
|
||
string Path = System.Text.Encoding.GetEncoding("GB2312").GetString(bytPath, 0, bytPath.Length);
|
||
OPENWX_TXT_PATH.Text = Path;
|
||
|
||
wxAPI.sc = new KstAPI.dele_Server_CallBack(Server_CallBack);
|
||
wxAPI.cc = new KstAPI.dele_Client_CallBack(Client_CallBack);
|
||
|
||
wxAPI.Socket_Port = wxAPI.Socket_Init(Marshal.GetFunctionPointerForDelegate(wxAPI.sc),
|
||
Marshal.GetFunctionPointerForDelegate(wxAPI.cc));
|
||
|
||
if(wxAPI.Socket_Port == 0)
|
||
{
|
||
MessageBox.Show("通信端口创建失败,请重试!","错误");
|
||
Environment.Exit(0);
|
||
}
|
||
|
||
Log("[初始化完成]" + Environment.NewLine + "服务端口:" + wxAPI.Socket_Port.ToString() + Environment.NewLine + "通信句柄:" + wxAPI.Socket_Handle.ToString());
|
||
|
||
KstAPI.kst_DLLConnect(201906061,wxAPI.Socket_Port);
|
||
}
|
||
|
||
void Log(string str)
|
||
{
|
||
str += Environment.NewLine + "--------------------------" + Environment.NewLine;
|
||
if(this.InvokeRequired == true)
|
||
{
|
||
this.Invoke((EventHandler)delegate
|
||
{
|
||
if(DEBUG_TXT.TextLength > 40000)
|
||
DEBUG_TXT.Clear();
|
||
DEBUG_TXT.AppendText(str);
|
||
});
|
||
}
|
||
else
|
||
{
|
||
DEBUG_TXT.AppendText(str);
|
||
}
|
||
}
|
||
|
||
int FindRowIndex(ListView lv, string text, int columnIndex)
|
||
{
|
||
foreach (ListViewItem li in lv.Items)
|
||
{
|
||
if (li.SubItems[columnIndex].Text == text)
|
||
{
|
||
return li.Index;
|
||
}
|
||
}
|
||
return -1;
|
||
}
|
||
|
||
Image ShowPicFromURL(string PicUrl)
|
||
{
|
||
WebRequest Request = (WebRequest)HttpWebRequest.Create(PicUrl);
|
||
WebResponse Resp = Request.GetResponse();
|
||
Stream stream = Resp.GetResponseStream();
|
||
Image Img = Image.FromStream(stream);
|
||
stream.Close();
|
||
Resp.Close();
|
||
return Img;
|
||
}
|
||
|
||
string SaveFile(string mWxid, string uWxid, string fName, string uName, string uExt, byte[] fData)
|
||
{
|
||
string filePath = Directory.GetCurrentDirectory() + "\\" + mWxid + "\\" + fName + "\\" + uWxid;
|
||
if(!Directory.Exists(filePath))
|
||
Directory.CreateDirectory(filePath);
|
||
filePath += "\\" + uName + "." + uExt;
|
||
FileStream fs = new FileStream(filePath, FileMode.Create);
|
||
fs.Write(fData, 0, fData.Length);
|
||
fs.Flush();
|
||
fs.Close();
|
||
return filePath;
|
||
}
|
||
|
||
string Timestamp2DataTime(long Timestamp)
|
||
{
|
||
System.DateTime dtDateTime = new DateTime(1970,1,1,8,0,0,0);
|
||
dtDateTime = dtDateTime.AddSeconds( Timestamp ).ToLocalTime();
|
||
return dtDateTime.ToString("yyyy-MM-dd HH:mm:ss");
|
||
}
|
||
|
||
string StrBetween(string sText, string sLeft, string sRight)
|
||
{
|
||
int i = sText.IndexOf(sLeft) + sLeft.Length;
|
||
string temp = sText.Substring(i, sText.IndexOf(sRight, i) - i);
|
||
return temp;
|
||
}
|
||
|
||
//服务端通信回调
|
||
void Server_CallBack(int sPoint, int so, int type, int buf, int buflen, int cso)
|
||
{
|
||
if(type == KstAPI.通信_连接成功)
|
||
{
|
||
wxAPI.Wx_Init(so,"C#-20190605");
|
||
}
|
||
else if(type == KstAPI.通信_连接断开)
|
||
{
|
||
int uIndex = FindRowIndex(LOGIN_LIST,so.ToString(),4);
|
||
if(uIndex != -1)
|
||
{
|
||
if(so == wxAPI.Client_Handle)
|
||
{
|
||
LOGIN_TXT_SOCKET.Text = "[未选择]";
|
||
LOGIN_TXT_NICK.Text = "[未选择]";
|
||
LOGIN_TXT_WXID.Text = "[未选择]";
|
||
PIC_HEADIMG.Image = null;
|
||
wxAPI.Client_Handle = 0;
|
||
wxAPI.Client_Wxid = "";
|
||
}
|
||
LOGIN_LIST.Items.RemoveAt(uIndex);
|
||
}
|
||
}
|
||
else if(type == KstAPI.通信_数据到达)
|
||
{
|
||
byte[] s_buf = new byte[buflen + 1];
|
||
KstAPI.RtlMoveMemory(s_buf,buf,buflen);
|
||
string s_Recv = Encoding.Default.GetString(s_buf).TrimEnd('\0');
|
||
|
||
//Log(s_Recv);
|
||
|
||
JObject recvJson = JObject.Parse(s_Recv);
|
||
int RecvType = (int)recvJson["packtype"];
|
||
|
||
if(RecvType == KstAPI.回调_二维码)
|
||
{
|
||
string B64_QRCode = recvJson["qrcode"].ToString();
|
||
byte[] imageBytes = Convert.FromBase64String(B64_QRCode);
|
||
MemoryStream ms = new MemoryStream(imageBytes, 0, imageBytes.Length);
|
||
ms.Write(imageBytes, 0, imageBytes.Length);
|
||
PIC_HEADIMG.Image = System.Drawing.Image.FromStream(ms, true);
|
||
}
|
||
else if(RecvType == KstAPI.回调_登录成功)
|
||
{
|
||
lock (SequenceLock)
|
||
{
|
||
ListViewItem UserItem = new ListViewItem();
|
||
|
||
UserItem.Text = recvJson["nick"].ToString();
|
||
UserItem.SubItems.Add(recvJson["wxid"].ToString());
|
||
UserItem.SubItems.Add(recvJson["wxno"].ToString());
|
||
UserItem.SubItems.Add(recvJson["himg"].ToString());
|
||
UserItem.SubItems.Add(so.ToString());
|
||
|
||
LOGIN_LIST.Items.Add(UserItem);
|
||
}
|
||
}
|
||
else if(RecvType == KstAPI.回调_退出登陆)
|
||
{
|
||
int uIndex = FindRowIndex(LOGIN_LIST,so.ToString(),4);
|
||
if(uIndex != -1)
|
||
{
|
||
if(so == wxAPI.Client_Handle)
|
||
{
|
||
LOGIN_TXT_SOCKET.Text = "[未选择]";
|
||
LOGIN_TXT_NICK.Text = "[未选择]";
|
||
LOGIN_TXT_WXID.Text = "[未选择]";
|
||
PIC_HEADIMG.Image = null;
|
||
wxAPI.Client_Handle = 0;
|
||
wxAPI.Client_Wxid = "";
|
||
}
|
||
LOGIN_LIST.Items.RemoveAt(uIndex);
|
||
}
|
||
}
|
||
else if(RecvType == KstAPI.回调_好友列表)
|
||
{
|
||
JArray uList = recvJson.Value<JArray>("list");
|
||
FRIEND_LIST.BeginUpdate();
|
||
FRIEND_GH_LIST.BeginUpdate();
|
||
GROUP_LIST.BeginUpdate();
|
||
for(int i=0;i<uList.Count;i++)
|
||
{
|
||
ListViewItem UserItem = new ListViewItem();
|
||
|
||
WeChatAPI.UserInfo uInfo = new WeChatAPI.UserInfo();
|
||
uInfo.Type = (int)recvJson["list"][i]["Type"];
|
||
uInfo.List = (int)recvJson["list"][i]["List"];
|
||
uInfo.Wxid = recvJson["list"][i]["Wxid"].ToString();
|
||
uInfo.WxNo = recvJson["list"][i]["WxNo"].ToString();
|
||
uInfo.Nick = recvJson["list"][i]["Nick"].ToString();
|
||
uInfo.Nick = KstAPI.DeUnicode(uInfo.Nick);
|
||
uInfo.Mark = recvJson["list"][i]["Mark"].ToString();
|
||
uInfo.Mark = KstAPI.DeUnicode(uInfo.Mark);
|
||
uInfo.HImg = recvJson["list"][i]["HImg"].ToString();
|
||
|
||
if(uInfo.Type == 8 || uInfo.Type == 24 || uInfo.Type == 29)
|
||
{//公众号
|
||
UserItem.Text = uInfo.Nick;
|
||
UserItem.SubItems.Add(uInfo.Wxid);
|
||
UserItem.SubItems.Add(uInfo.WxNo);
|
||
UserItem.SubItems.Add(uInfo.HImg);
|
||
FRIEND_GH_LIST.Items.Add(UserItem);
|
||
}
|
||
else if(uInfo.Wxid.LastIndexOf("@chatroom") != -1)
|
||
{//群
|
||
if(uInfo.Nick == "")
|
||
uInfo.Nick = "群聊";
|
||
UserItem.Text = uInfo.Nick;
|
||
UserItem.SubItems.Add(uInfo.Wxid);
|
||
UserItem.SubItems.Add(uInfo.WxNo);
|
||
UserItem.SubItems.Add(uInfo.List.ToString());
|
||
UserItem.SubItems.Add(uInfo.HImg);
|
||
GROUP_LIST.Items.Add(UserItem);
|
||
}
|
||
else if(uInfo.List != 2)
|
||
{//好友
|
||
UserItem.Text = uInfo.Nick;
|
||
UserItem.SubItems.Add(uInfo.Mark);
|
||
UserItem.SubItems.Add(uInfo.Wxid);
|
||
UserItem.SubItems.Add(uInfo.WxNo);
|
||
UserItem.SubItems.Add(uInfo.HImg);
|
||
FRIEND_LIST.Items.Add(UserItem);
|
||
}
|
||
}
|
||
FRIEND_LIST.EndUpdate();
|
||
FRIEND_GH_LIST.EndUpdate();
|
||
GROUP_LIST.EndUpdate();
|
||
|
||
string OutLog = "[刷新好友列表][" + recvJson["mywxid"].ToString() + "]" + Environment.NewLine +
|
||
"好友数:" + FRIEND_LIST.Items.Count.ToString() + Environment.NewLine +
|
||
"公众号:" + FRIEND_GH_LIST.Items.Count.ToString() + Environment.NewLine +
|
||
"群聊数:" + GROUP_LIST.Items.Count.ToString();
|
||
Log(OutLog);
|
||
|
||
|
||
}
|
||
else if(RecvType == KstAPI.回调_群员列表)
|
||
{
|
||
JArray uList = recvJson.Value<JArray>("list");
|
||
|
||
GROUP_MEMBER_LIST.BeginUpdate();
|
||
for(int i=0;i<uList.Count;i++)
|
||
{
|
||
ListViewItem UserItem = new ListViewItem();
|
||
|
||
UserItem.Text = KstAPI.DeUnicode(recvJson["list"][i]["Nick"].ToString());
|
||
UserItem.SubItems.Add(KstAPI.DeUnicode(recvJson["list"][i]["Mark"].ToString()));
|
||
UserItem.SubItems.Add(recvJson["list"][i]["Wxid"].ToString());
|
||
UserItem.SubItems.Add(recvJson["list"][i]["HImg"].ToString());
|
||
|
||
GROUP_MEMBER_LIST.Items.Add(UserItem);
|
||
}
|
||
GROUP_MEMBER_LIST.EndUpdate();
|
||
}
|
||
else if(RecvType == KstAPI.回调_接收消息)
|
||
{
|
||
WeChatAPI.MsgInfo mInfo = new WeChatAPI.MsgInfo();
|
||
mInfo.RecvWxid = recvJson["mywxid"].ToString();
|
||
mInfo.Type = (int)recvJson["type"];
|
||
mInfo.Time = Timestamp2DataTime((int)recvJson["time"]);
|
||
mInfo.IsSend = (int)recvJson["isme"];
|
||
mInfo.LocalMsgID = (int)recvJson["msgid"];
|
||
mInfo.ServerMsgID = recvJson["smsgid"].ToString();
|
||
mInfo.Wxid_1 = recvJson["wxid1"].ToString();
|
||
mInfo.Wxid_2 = recvJson["wxid2"].ToString();
|
||
mInfo.Msg = Encoding.Default.GetString(Convert.FromBase64String(recvJson["msg"].ToString()));
|
||
mInfo.Msg = KstAPI.DeUnicode(mInfo.Msg);
|
||
mInfo.Source = Encoding.Default.GetString(Convert.FromBase64String(recvJson["source"].ToString()));
|
||
string OutLog;
|
||
if(mInfo.IsSend == 0)
|
||
OutLog = "[接收消息]";
|
||
else
|
||
OutLog = "[发送消息]";
|
||
|
||
OutLog += "[" + mInfo.Time + "][" + mInfo.RecvWxid + "]" + Environment.NewLine +
|
||
"Type:" + mInfo.Type.ToString() + Environment.NewLine +
|
||
"消息ID:" + mInfo.LocalMsgID.ToString() + Environment.NewLine +
|
||
"服务ID:" + mInfo.ServerMsgID + Environment.NewLine +
|
||
"Wxid_1:" + mInfo.Wxid_1 + Environment.NewLine +
|
||
"Wxid_2:" + mInfo.Wxid_2 + Environment.NewLine +
|
||
//"消息内容:" + mInfo.Msg + " | " + temmsg + Environment.NewLine +
|
||
"消息内容:" + mInfo.Msg + Environment.NewLine +
|
||
"附加内容:" + mInfo.Source;
|
||
|
||
|
||
Log(OutLog);
|
||
|
||
if(mInfo.Type == 37)//好友请求
|
||
{
|
||
|
||
|
||
if(CHK_ADDFRIEND.Checked == true)
|
||
{
|
||
string Add_v1 = StrBetween(mInfo.Msg, "encryptusername=\"", "\" fromnickname=");
|
||
string Add_v2 = StrBetween(mInfo.Msg, "ticket=\"", "\" opcode=");
|
||
wxAPI.Wx_AddFriend(so, 3, 14, Add_v1, Add_v2, "");
|
||
}
|
||
}
|
||
else if(mInfo.Type == 49 && mInfo.Msg.IndexOf("微信转账") != -1 && mInfo.Msg.IndexOf("收到转账") != -1)
|
||
{
|
||
if(CHK_MONEY.Checked == true)
|
||
{
|
||
string sState = StrBetween(mInfo.Msg, "<paysubtype>", "</paysubtype>");
|
||
string sTranID = StrBetween(mInfo.Msg, "transferid><![CDATA[", "]]></transferid>");
|
||
string sTime = StrBetween(mInfo.Msg, "<invalidtime><![CDATA[", "]]></invalidtime>");
|
||
if(sState == "1" && mInfo.IsSend == 0)
|
||
wxAPI.Wx_GetMoney(so, mInfo.Wxid_1, sTranID, int.Parse(sTime));
|
||
|
||
}
|
||
}
|
||
else if(mInfo.Type == 49 && mInfo.Msg.IndexOf("邀请你加入群聊") != -1 && mInfo.IsSend == 0)
|
||
{
|
||
if(CHK_INVITE.Checked == true)
|
||
{
|
||
string inviteURL = StrBetween(mInfo.Msg, "<url><![CDATA[", "]]></url>");
|
||
if(inviteURL != "")
|
||
wxAPI.Wx_GetA8Key(so, 1, mInfo.Wxid_1, inviteURL);
|
||
}
|
||
}
|
||
}
|
||
else if(RecvType == KstAPI.回调_语音消息 ||
|
||
RecvType == KstAPI.回调_视频消息 ||
|
||
RecvType == KstAPI.回调_文件消息 ||
|
||
RecvType == KstAPI.回调_图片消息)
|
||
{
|
||
WeChatAPI.MsgInfo mInfo = new WeChatAPI.MsgInfo();
|
||
mInfo.RecvWxid = recvJson["mywxid"].ToString();
|
||
mInfo.Type = (int)recvJson["type"];
|
||
mInfo.Time = Timestamp2DataTime((int)recvJson["time"]);
|
||
mInfo.IsSend = (int)recvJson["isme"];
|
||
mInfo.LocalMsgID = (int)recvJson["msgid"];
|
||
mInfo.ServerMsgID = recvJson["smsgid"].ToString();
|
||
mInfo.Wxid_1 = recvJson["wxid1"].ToString();
|
||
mInfo.Wxid_2 = recvJson["wxid2"].ToString();
|
||
mInfo.Msg = Encoding.Default.GetString(Convert.FromBase64String(recvJson["msg"].ToString()));
|
||
if(RecvType == KstAPI.回调_语音消息)
|
||
{
|
||
byte[] silkByte = Convert.FromBase64String(recvJson["source"].ToString());
|
||
mInfo.Source = SaveFile(mInfo.RecvWxid, mInfo.Wxid_1, "VOICE", mInfo.ServerMsgID, "silk", silkByte);
|
||
}
|
||
else if(RecvType == KstAPI.回调_图片消息)
|
||
{
|
||
byte[] ImageByte = Convert.FromBase64String(recvJson["source"].ToString());
|
||
mInfo.Source = SaveFile(mInfo.RecvWxid, mInfo.Wxid_1, "IMAGE", mInfo.ServerMsgID, "jpg", ImageByte);
|
||
|
||
string MaxPicPath = mInfo.Source.Replace(mInfo.ServerMsgID, mInfo.ServerMsgID + "_MAX");
|
||
if(CHK_PIC.Checked == true)
|
||
//wxAPI.DownLoadPic(so, mInfo.Msg, MaxPicPath);
|
||
wxAPI.DownLoadPic(so, mInfo.Msg, "C:\\rra\\MAX_.jpg");
|
||
}
|
||
else
|
||
{
|
||
mInfo.Source = recvJson["source"].ToString();
|
||
}
|
||
|
||
|
||
string OutLog;
|
||
if(mInfo.IsSend == 0)
|
||
OutLog = "[接收消息]";
|
||
else
|
||
OutLog = "[发送消息]";
|
||
|
||
OutLog += "[" + mInfo.Time + "][" + mInfo.RecvWxid + "]" + Environment.NewLine +
|
||
"Type:" + mInfo.Type.ToString() + Environment.NewLine +
|
||
"消息ID:" + mInfo.LocalMsgID.ToString() + Environment.NewLine +
|
||
"服务ID:" + mInfo.ServerMsgID + Environment.NewLine +
|
||
"Wxid_1:" + mInfo.Wxid_1 + Environment.NewLine +
|
||
"Wxid_2:" + mInfo.Wxid_2 + Environment.NewLine +
|
||
"消息内容:" + mInfo.Msg + Environment.NewLine +
|
||
"文件路径:" + mInfo.Source;
|
||
Log(OutLog);
|
||
}
|
||
else if(RecvType == KstAPI.回调_添加好友)
|
||
{
|
||
string RecvWxid = recvJson["mywxid"].ToString();
|
||
int uType = (int)recvJson["id"];
|
||
int uSource = (int)recvJson["scene"];
|
||
string uWxid = recvJson["wxid"].ToString();
|
||
Log("[添加好友][" + RecvWxid + "]" + Environment.NewLine + "返回类型:" + uType.ToString() + Environment.NewLine +
|
||
"添加来源:" + uSource.ToString() + Environment.NewLine +
|
||
"添加Wxid:" + uWxid);
|
||
if(uType == -44)//需要验证
|
||
{
|
||
wxAPI.Wx_AddFriend(so, 2, uSource, uWxid, "", FRI_TXT_MSG.Text);
|
||
}
|
||
}
|
||
else if(RecvType == KstAPI.回调_下载信息)
|
||
{
|
||
WeChatAPI.UserInfo uInfo = new WeChatAPI.UserInfo();
|
||
uInfo.Wxid = recvJson["info"]["Wxid"].ToString();
|
||
uInfo.WxNo = recvJson["info"]["WxNo"].ToString();
|
||
uInfo.Nick = recvJson["info"]["Nick"].ToString();
|
||
uInfo.Nick = KstAPI.DeUnicode(uInfo.Nick);
|
||
uInfo.V1 = recvJson["info"]["v1"].ToString();
|
||
uInfo.HImg = recvJson["info"]["HImg"].ToString();
|
||
uInfo.Sex = uInfo.GetSex((int)recvJson["info"]["Sex"]);
|
||
uInfo.Address = recvJson["info"]["Address"].ToString();
|
||
string OutLog = "[详细信息][" + recvJson["mywxid"].ToString() + "]" + Environment.NewLine +
|
||
"Wxid:" + uInfo.Wxid + Environment.NewLine +
|
||
"微信号:" + uInfo.WxNo + Environment.NewLine +
|
||
"昵称:" + uInfo.Nick + Environment.NewLine +
|
||
"性别:" + uInfo.Sex + Environment.NewLine +
|
||
"地区:" + uInfo.Address + Environment.NewLine +
|
||
"v1:" + uInfo.V1 + Environment.NewLine +
|
||
"头像:" + uInfo.HImg;
|
||
Log(OutLog);
|
||
}
|
||
else if(RecvType == KstAPI.回调_建群返回)
|
||
{
|
||
string cdata = recvJson["data"].ToString();
|
||
string RecvWxid = recvJson["mywxid"].ToString();
|
||
if(cdata == "Everything is OK")
|
||
{
|
||
string OutLog = "[建群返回][" + RecvWxid + "]" + Environment.NewLine;
|
||
string GroupID = recvJson["gid"].ToString();
|
||
OutLog += "群ID:" + GroupID + Environment.NewLine + "成员:"+ Environment.NewLine;
|
||
JArray mList = recvJson.Value<JArray>("list");
|
||
for(int i=0;i<mList.Count;i++)
|
||
{
|
||
string uWxid = recvJson["list"][i]["wxid"].ToString();
|
||
string uState = recvJson["list"][i]["status"].ToString();
|
||
if(uState == "1")
|
||
OutLog += "成功 --> " + uWxid + Environment.NewLine;
|
||
else
|
||
OutLog += "失败 --> " + uWxid + Environment.NewLine;
|
||
}
|
||
Log(OutLog);
|
||
}
|
||
else
|
||
Log("[建群返回][" + RecvWxid + "]" + Environment.NewLine + "建群失败!");
|
||
}
|
||
else if(RecvType == KstAPI.回调_A8Key)
|
||
{
|
||
string RecvWxid = recvJson["mywxid"].ToString();
|
||
string LastURL = recvJson["lasturl"].ToString();
|
||
string NowURL = recvJson["url"].ToString();
|
||
Log("[GetA8Key][" + RecvWxid + "]" + Environment.NewLine + "访问链接:" + LastURL + Environment.NewLine + "返回链接:" + NowURL);
|
||
if(NowURL.IndexOf("addchatroombyinvite") != -1)
|
||
{
|
||
HttpWebRequest Request = (HttpWebRequest)HttpWebRequest.Create(NowURL);
|
||
Request.Method = "POST";
|
||
Request.AllowAutoRedirect = false;
|
||
Request.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8";
|
||
Request.UserAgent = "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.95 Safari/537.36 MicroMessenger/6.5.2.501 NetType/WIFI WindowsWechat QBCore/3.43.556.400 QQBrowser/9.0.2524.400";
|
||
Request.Referer = NowURL;
|
||
Request.Headers.Add("Accept-Language","zh-CN,zh;q=0.8,en-us;q=0.6,en;q=0.5;q=0.4");
|
||
HttpWebResponse Response = (HttpWebResponse)Request.GetResponse();
|
||
string hLocation = Response.GetResponseHeader("Location").ToString();
|
||
if(hLocation != "")
|
||
{
|
||
if(hLocation.IndexOf("chatroom") != -1)
|
||
{
|
||
string GroupID = StrBetween(hLocation,"weixin://jump/mainframe/" ,"@chatroom");
|
||
Log("[入群成功][" + RecvWxid + "]" + Environment.NewLine + "群号:" + GroupID + "@chatroom");
|
||
}
|
||
}
|
||
}
|
||
}
|
||
else if(RecvType == KstAPI.回调_聊天对象)
|
||
{
|
||
WeChatAPI.UserInfo uInfo = new WeChatAPI.UserInfo();
|
||
uInfo.Wxid = recvJson["wxid"].ToString();
|
||
uInfo.WxNo = recvJson["wxno"].ToString();
|
||
uInfo.Nick = recvJson["nick"].ToString();
|
||
uInfo.Nick = KstAPI.DeUnicode(uInfo.Nick);
|
||
uInfo.Mark = recvJson["mark"].ToString();
|
||
uInfo.Mark = KstAPI.DeUnicode(uInfo.Mark);
|
||
uInfo.HImg = recvJson["himg"].ToString();
|
||
|
||
string OutLog = "[聊天对象][" + recvJson["mywxid"].ToString() + "]" + Environment.NewLine +
|
||
"Wxid:" + uInfo.Wxid + Environment.NewLine +
|
||
"微信号:" + uInfo.WxNo + Environment.NewLine +
|
||
"昵称:" + uInfo.Nick + Environment.NewLine +
|
||
"备注:" + uInfo.Mark + Environment.NewLine +
|
||
"头像:" + uInfo.HImg;
|
||
Log(OutLog);
|
||
}
|
||
}
|
||
}
|
||
|
||
void Client_CallBack(int so, int sPoint, int type, int buf, int buflen)
|
||
{
|
||
|
||
}
|
||
|
||
//登录列表框选择事件
|
||
void LOGIN_LISTItemCheck(object sender, ItemCheckEventArgs e)
|
||
{
|
||
if (!LOGIN_LIST.Items[e.Index].Checked)
|
||
{
|
||
foreach (ListViewItem lv in LOGIN_LIST.Items)
|
||
{
|
||
if (lv.Checked)
|
||
{
|
||
lv.Checked = false;
|
||
lv.Selected = false;
|
||
}
|
||
}
|
||
|
||
wxAPI.Client_Handle = int.Parse(LOGIN_LIST.Items[e.Index].SubItems[4].Text);
|
||
wxAPI.Client_Wxid = LOGIN_LIST.Items[e.Index].SubItems[1].Text;
|
||
LOGIN_TXT_SOCKET.Text = LOGIN_LIST.Items[e.Index].SubItems[4].Text;
|
||
LOGIN_TXT_NICK.Text = LOGIN_LIST.Items[e.Index].SubItems[0].Text;
|
||
LOGIN_TXT_WXID.Text = wxAPI.Client_Wxid;
|
||
|
||
string HImgUrl = LOGIN_LIST.Items[e.Index].SubItems[3].Text;
|
||
if(HImgUrl.Length > 10)
|
||
{
|
||
if(HImgUrl.Substring(0,4) == "http")
|
||
{
|
||
PIC_HEADIMG.Image = ShowPicFromURL(HImgUrl);
|
||
}
|
||
}
|
||
}
|
||
else
|
||
{
|
||
wxAPI.Client_Handle = 0;
|
||
LOGIN_TXT_SOCKET.Text = "[未选择]";
|
||
LOGIN_TXT_NICK.Text = "[未选择]";
|
||
LOGIN_TXT_WXID.Text = "[未选择]";
|
||
PIC_HEADIMG.Image = null;
|
||
}
|
||
}
|
||
|
||
//好友列表框单击事件
|
||
void FRIEND_LISTMouseClick(object sender, MouseEventArgs e)
|
||
{
|
||
if(e.Button == MouseButtons.Right)
|
||
{
|
||
ListViewItem xy = FRIEND_LIST.GetItemAt(e.X, e.Y);
|
||
if (xy != null)
|
||
{
|
||
Point point = this.PointToClient(FRIEND_LIST.PointToScreen(new Point(e.X, e.Y)));
|
||
this.FRIEND_MENU.Show(this, point);
|
||
}
|
||
}
|
||
else
|
||
{
|
||
if(FRIEND_LIST.FocusedItem != null)
|
||
{
|
||
string HImgUrl = FRIEND_LIST.FocusedItem.SubItems[4].Text;
|
||
if(HImgUrl.Length > 10)
|
||
{
|
||
if(HImgUrl.Substring(0,4) == "http")
|
||
{
|
||
PIC_HEADIMG.Image = ShowPicFromURL(HImgUrl);
|
||
}
|
||
}
|
||
|
||
string uWxid = FRIEND_LIST.FocusedItem.SubItems[2].Text;
|
||
MSG_TXT_WXID.Text = uWxid;
|
||
FRI_TXT_WXID.Text = uWxid;
|
||
MSG_TXT_ATWXID.Text = "";
|
||
}
|
||
}
|
||
}
|
||
//好友列表菜单操作
|
||
//mType:0=下载信息 1=置顶 2=免打扰
|
||
void FriendList_Menu(int mType,int mCheck = 0)
|
||
{
|
||
if(FRIEND_LIST.FocusedItem != null)
|
||
{
|
||
string uWxid = FRIEND_LIST.FocusedItem.SubItems[2].Text;
|
||
if(wxAPI.Client_Handle == 0)
|
||
MessageBox.Show("请选择一个操作账号!","错误");
|
||
else if(uWxid == "")
|
||
MessageBox.Show("请选择一个需要查询的Wxid!","错误");
|
||
else
|
||
{
|
||
if(mType == 0)
|
||
wxAPI.Wx_GetUserInfo(wxAPI.Client_Handle, uWxid, string.Empty);
|
||
else
|
||
wxAPI.Wx_StateOpt(wxAPI.Client_Handle, mType, uWxid, mCheck);
|
||
|
||
}
|
||
}
|
||
}
|
||
//好友列表菜单-下载详细信息被点击
|
||
void FRIEND_MENU_GETUSERINFOClick(object sender, EventArgs e)
|
||
{
|
||
FriendList_Menu(0);
|
||
}
|
||
//好友列表菜单-置顶聊天
|
||
void FRIEND_MENU_TOP_ONClick(object sender, EventArgs e)
|
||
{
|
||
FriendList_Menu(1,1);
|
||
}
|
||
//好友列表菜单-取消置顶
|
||
void FRIEND_MENU_TOP_OFFClick(object sender, EventArgs e)
|
||
{
|
||
FriendList_Menu(1,0);
|
||
}
|
||
//好友列表菜单-开启免打扰
|
||
void FRIEND_MENU_DISTURB_ONClick(object sender, EventArgs e)
|
||
{
|
||
FriendList_Menu(2,0);
|
||
}
|
||
//好友列表菜单-取消免打扰
|
||
void FRIEND_MENU_DISTURB_OFFClick(object sender, EventArgs e)
|
||
{
|
||
FriendList_Menu(2,1);
|
||
}
|
||
//群列表框单击事件
|
||
void GROUP_LISTMouseClick(object sender, MouseEventArgs e)
|
||
{
|
||
if(e.Button == MouseButtons.Right)
|
||
{
|
||
ListViewItem xy = GROUP_LIST.GetItemAt(e.X, e.Y);
|
||
if (xy != null)
|
||
{
|
||
Point point = this.PointToClient(GROUP_LIST.PointToScreen(new Point(e.X, e.Y)));
|
||
this.GROUP_MENU.Show(this, point);
|
||
}
|
||
}
|
||
else
|
||
{
|
||
if(GROUP_LIST.FocusedItem != null)
|
||
{
|
||
string uGroupID = GROUP_LIST.FocusedItem.SubItems[1].Text;
|
||
MSG_TXT_WXID.Text = uGroupID;
|
||
GROUP_TXT_GID.Text = uGroupID;
|
||
}
|
||
}
|
||
|
||
}
|
||
//群列表菜单操作
|
||
//mType:1=置顶 2=免打扰 3=保存通讯录 4=显示群员昵称
|
||
void GroupList_Menu(int mType,int mCheck = 0)
|
||
{
|
||
if(GROUP_LIST.FocusedItem != null)
|
||
{
|
||
string uWxid = GROUP_LIST.FocusedItem.SubItems[1].Text;
|
||
if(wxAPI.Client_Handle == 0)
|
||
MessageBox.Show("请选择一个操作账号!","错误");
|
||
else if(uWxid == "")
|
||
MessageBox.Show("请选择一个需要查询的Wxid!","错误");
|
||
else
|
||
wxAPI.Wx_StateOpt(wxAPI.Client_Handle, mType, uWxid, mCheck);
|
||
}
|
||
}
|
||
//群聊菜单-设置置顶
|
||
void GROUP_MENU_TOP_ONClick(object sender, EventArgs e)
|
||
{
|
||
GroupList_Menu(1,1);
|
||
}
|
||
//群聊菜单-取消置顶
|
||
void GROUP_MENU_TOP_OFFClick(object sender, EventArgs e)
|
||
{
|
||
GroupList_Menu(1,0);
|
||
}
|
||
//群聊菜单-开启免打扰
|
||
void GROUP_MENU_DISTURB_ONClick(object sender, EventArgs e)
|
||
{
|
||
GroupList_Menu(2,0);
|
||
}
|
||
//群聊菜单-取消免打扰
|
||
void GROUP_MENU_DISTURB_OFFClick(object sender, EventArgs e)
|
||
{
|
||
GroupList_Menu(2,1);
|
||
}
|
||
//群聊菜单-保存通讯录
|
||
void GROUP_MENU_SAVE_ONClick(object sender, EventArgs e)
|
||
{
|
||
GroupList_Menu(3,1);
|
||
}
|
||
//群聊菜单-取消保存通讯录
|
||
void GROUP_MENU_SAVE_OFFClick(object sender, EventArgs e)
|
||
{
|
||
GroupList_Menu(3,0);
|
||
}
|
||
//群聊菜单-显示群员昵称
|
||
void GROUP_MENU_NICK_ONClick(object sender, EventArgs e)
|
||
{
|
||
GroupList_Menu(4,1);
|
||
}
|
||
//群聊菜单-取消显示群员昵称
|
||
void GROUP_MENU_NICK_OFFClick(object sender, EventArgs e)
|
||
{
|
||
GroupList_Menu(4,0);
|
||
}
|
||
//群列表框双击事件
|
||
void GROUP_LISTMouseDoubleClick(object sender, MouseEventArgs e)
|
||
{
|
||
if(GROUP_LIST.FocusedItem != null)
|
||
{
|
||
string uGroupID = GROUP_LIST.FocusedItem.SubItems[1].Text;
|
||
if(wxAPI.Client_Handle != 0)
|
||
{
|
||
GROUP_MEMBER_LIST.Items.Clear();
|
||
wxAPI.Client_GroupID = uGroupID;
|
||
wxAPI.Wx_ReGroupList(wxAPI.Client_Handle, uGroupID);
|
||
}
|
||
}
|
||
}
|
||
//群员列表框单击事件
|
||
void GROUP_MEMBER_LISTMouseClick(object sender, MouseEventArgs e)
|
||
{
|
||
if(e.Button == MouseButtons.Right)
|
||
{
|
||
ListViewItem xy = GROUP_MEMBER_LIST.GetItemAt(e.X, e.Y);
|
||
if (xy != null)
|
||
{
|
||
Point point = this.PointToClient(GROUP_MEMBER_LIST.PointToScreen(new Point(e.X, e.Y)));
|
||
this.GROUPMEMBER_MENU.Show(this, point);
|
||
}
|
||
}
|
||
else
|
||
{
|
||
if(GROUP_MEMBER_LIST.FocusedItem != null)
|
||
{
|
||
string uWxid = GROUP_MEMBER_LIST.FocusedItem.SubItems[2].Text;
|
||
MSG_TXT_ATWXID.Text = uWxid;
|
||
GROUP_TXT_WXID.Text = uWxid;
|
||
}
|
||
}
|
||
}
|
||
//群成员菜单-下载详细信息被点击
|
||
void GROUPMEMBER_MENU_GETUSERINFOClick(object sender, EventArgs e)
|
||
{
|
||
if(GROUP_MEMBER_LIST.FocusedItem != null)
|
||
{
|
||
string uWxid = GROUP_MEMBER_LIST.FocusedItem.SubItems[2].Text;
|
||
if(wxAPI.Client_Handle == 0)
|
||
MessageBox.Show("请选择一个操作账号!","错误");
|
||
else if(uWxid == "")
|
||
MessageBox.Show("请选择一个需要查询的Wxid!","错误");
|
||
else if(wxAPI.Client_GroupID == "")
|
||
MessageBox.Show("操作失败,群ID为空!","错误");
|
||
else
|
||
wxAPI.Wx_GetUserInfo(wxAPI.Client_Handle, uWxid, wxAPI.Client_GroupID);
|
||
}
|
||
}
|
||
|
||
//创建一个微信进程
|
||
void BUTTON_OPEMWXClick(object sender, EventArgs e)
|
||
{
|
||
if(OPENWX_TXT_PATH.Text != "")
|
||
{
|
||
int dwPid = KstAPI.kst_CreateWx(OPENWX_TXT_PATH.Text, "WeChat.exe", "kst.dll", wxAPI.Socket_Port);
|
||
Log("[创建微信进程]"+Environment.NewLine+"进程PID:"+dwPid.ToString());
|
||
}
|
||
}
|
||
|
||
//刷新好友/公众号/群列表
|
||
void BUTTON_RE_LISTClick(object sender, EventArgs e)
|
||
{
|
||
if(wxAPI.Client_Handle == 0)
|
||
MessageBox.Show("请选择一个操作账号!","错误");
|
||
else
|
||
FRIEND_LIST.Items.Clear();
|
||
FRIEND_GH_LIST.Items.Clear();
|
||
GROUP_LIST.Items.Clear();
|
||
GROUP_MEMBER_LIST.Items.Clear();
|
||
wxAPI.Wx_ReFriendList(wxAPI.Client_Handle);
|
||
}
|
||
//发送文本消息
|
||
void BUTTON_MSG_TEXTClick(object sender, EventArgs e)
|
||
{
|
||
if(wxAPI.Client_Handle == 0)
|
||
MessageBox.Show("请选择一个操作账号!","错误");
|
||
else if(MSG_TXT_WXID.Text == "")
|
||
MessageBox.Show("请输入接收消息者的Wxid!","错误");
|
||
else if(MSG_TXT_MESSAGE.Text == "")
|
||
MessageBox.Show("请输入欲发送的消息内容!","错误");
|
||
else
|
||
{
|
||
string uMessage = KstAPI.EnUnicode(MSG_TXT_MESSAGE.Text);
|
||
wxAPI.Wx_SendTextMsg(wxAPI.Client_Handle, MSG_TXT_WXID.Text, MSG_TXT_ATWXID.Text, uMessage);
|
||
}
|
||
}
|
||
//发送图片消息
|
||
void BUTTON_MSG_PICClick(object sender, EventArgs e)
|
||
{
|
||
if(wxAPI.Client_Handle == 0)
|
||
MessageBox.Show("请选择一个操作账号!","错误");
|
||
else if(MSG_TXT_WXID.Text == "")
|
||
MessageBox.Show("请输入接收消息者的Wxid!","错误");
|
||
else if(!File.Exists(MSG_TXT_MESSAGE.Text))
|
||
MessageBox.Show("欲发送的图片文件不存在!","错误");
|
||
else
|
||
wxAPI.Wx_SendFileMsg(wxAPI.Client_Handle, 1, MSG_TXT_WXID.Text, MSG_TXT_MESSAGE.Text);
|
||
}
|
||
//发送GIF动图
|
||
void BUTTON_MSG_GIFClick(object sender, EventArgs e)
|
||
{
|
||
if(wxAPI.Client_Handle == 0)
|
||
MessageBox.Show("请选择一个操作账号!","错误");
|
||
else if(MSG_TXT_WXID.Text == "")
|
||
MessageBox.Show("请输入接收消息者的Wxid!","错误");
|
||
else if(!File.Exists(MSG_TXT_MESSAGE.Text))
|
||
MessageBox.Show("欲发送的GIF文件不存在!","错误");
|
||
else
|
||
wxAPI.Wx_SendFileMsg(wxAPI.Client_Handle, 2, MSG_TXT_WXID.Text, MSG_TXT_MESSAGE.Text);
|
||
}
|
||
//发送文件/视频
|
||
void BUTTON_MSG_FILEClick(object sender, EventArgs e)
|
||
{
|
||
if(wxAPI.Client_Handle == 0)
|
||
MessageBox.Show("请选择一个操作账号!","错误");
|
||
else if(MSG_TXT_WXID.Text == "")
|
||
MessageBox.Show("请输入接收消息者的Wxid!","错误");
|
||
else if(!File.Exists(MSG_TXT_MESSAGE.Text))
|
||
MessageBox.Show("欲发送的文件不存在!","错误");
|
||
else
|
||
wxAPI.Wx_SendFileMsg(wxAPI.Client_Handle, 3, MSG_TXT_WXID.Text, MSG_TXT_MESSAGE.Text);
|
||
}
|
||
//发送名片
|
||
void BUTTON_MSG_CARDClick(object sender, EventArgs e)
|
||
{
|
||
if(wxAPI.Client_Handle == 0)
|
||
MessageBox.Show("请选择一个操作账号!","错误");
|
||
else if(MSG_TXT_WXID.Text == "")
|
||
MessageBox.Show("请输入接收消息者的Wxid!","错误");
|
||
else
|
||
wxAPI.Wx_SendCardMsg(wxAPI.Client_Handle, 1, MSG_TXT_WXID.Text, wxAPI.Client_Wxid);
|
||
}
|
||
//发送定位消息
|
||
void BUTTON_MSG_MAPClick(object sender, EventArgs e)
|
||
{
|
||
Assembly mAsm = Assembly.GetExecutingAssembly();
|
||
ResourceManager resMan = new ResourceManager("WxRobot.API.WxXML", mAsm);
|
||
string XML = resMan.GetString("MAP_XML");
|
||
if(wxAPI.Client_Handle == 0)
|
||
MessageBox.Show("请选择一个操作账号!","错误");
|
||
else if(MSG_TXT_WXID.Text == "")
|
||
MessageBox.Show("请输入接收消息者的Wxid!","错误");
|
||
else
|
||
{
|
||
XML = XML.Replace("*坐标X*", "39.903740");
|
||
XML = XML.Replace("*坐标Y*", "116.397827");
|
||
XML = XML.Replace("*主标题*", "天安门广场");
|
||
XML = XML.Replace("*副标题*", "北京市东城区东长安街");
|
||
wxAPI.Wx_SendMapMsg(wxAPI.Client_Handle, MSG_TXT_WXID.Text, XML);
|
||
}
|
||
}
|
||
//发送收藏消息
|
||
void BUTTON_MSG_FAVClick(object sender, EventArgs e)
|
||
{
|
||
int uIndex;
|
||
if(wxAPI.Client_Handle == 0)
|
||
MessageBox.Show("请选择一个操作账号!","错误");
|
||
else if(MSG_TXT_WXID.Text == "")
|
||
MessageBox.Show("请输入接收消息者的Wxid!","错误");
|
||
else if(!int.TryParse(MSG_TXT_MESSAGE.Text, out uIndex))
|
||
MessageBox.Show("请在[uMsg]输入欲发送的收藏序号(由0开始)","错误");
|
||
else
|
||
wxAPI.Wx_SendFavMsg(wxAPI.Client_Handle, MSG_TXT_WXID.Text, uIndex);
|
||
}
|
||
//发送自定义链接
|
||
void BUTTON_MSG_URLClick(object sender, EventArgs e)
|
||
{
|
||
Assembly mAsm = Assembly.GetExecutingAssembly();
|
||
ResourceManager resMan = new ResourceManager("WxRobot.API.WxXML", mAsm);
|
||
string XML = resMan.GetString("URL_XML");
|
||
if(wxAPI.Client_Handle == 0)
|
||
MessageBox.Show("请选择一个操作账号!","错误");
|
||
else if(MSG_TXT_WXID.Text == "")
|
||
MessageBox.Show("请输入接收消息者的Wxid!","错误");
|
||
else if(URL_TXT_TITLE.Text == "")
|
||
MessageBox.Show("请输入链接消息的标题!","错误");
|
||
else if(URL_TXT_TEXT.Text == "")
|
||
MessageBox.Show("请输入链接消息的摘要!","错误");
|
||
else if(URL_TXT_PIC.Text == "")
|
||
MessageBox.Show("请输入链接消息的图片地址!","错误");
|
||
else if(URL_TXT_URL.Text == "")
|
||
MessageBox.Show("请输入链接消息的链接地址!","错误");
|
||
else
|
||
{
|
||
XML = XML.Replace("*MYWXID*",wxAPI.Client_Wxid);
|
||
XML = XML.Replace("*标题*",URL_TXT_TITLE.Text);
|
||
XML = XML.Replace("*摘要*",URL_TXT_TEXT.Text);
|
||
XML = XML.Replace("*图片*",URL_TXT_PIC.Text);
|
||
XML = XML.Replace("*地址*",URL_TXT_URL.Text);
|
||
wxAPI.Wx_SendURLMsg(wxAPI.Client_Handle, MSG_TXT_WXID.Text, wxAPI.Client_Wxid, XML);
|
||
}
|
||
}
|
||
//加好友
|
||
void BUTTON_FRI_ADDClick(object sender, EventArgs e)
|
||
{
|
||
int uSource;
|
||
if(wxAPI.Client_Handle == 0)
|
||
MessageBox.Show("请选择一个操作账号!","错误");
|
||
else if(FRI_TXT_WXID.Text == "")
|
||
MessageBox.Show("请输入需要添加的Wxid!","错误");
|
||
else if(!int.TryParse(FRI_TXT_SOURCE.Text,out uSource))
|
||
MessageBox.Show("请输入需要添加的Wxid!","错误");
|
||
else
|
||
wxAPI.Wx_AddFriend(wxAPI.Client_Handle, 1, uSource, FRI_TXT_WXID.Text, "", FRI_TXT_MSG.Text);
|
||
}
|
||
//删好友
|
||
void BUTTON_FRI_DELClick(object sender, EventArgs e)
|
||
{
|
||
if(wxAPI.Client_Handle == 0)
|
||
MessageBox.Show("请选择一个操作账号!","错误");
|
||
else if(FRI_TXT_WXID.Text == "")
|
||
MessageBox.Show("请输入需要删除的好友Wxid!","错误");
|
||
else
|
||
wxAPI.Wx_DelFriend(wxAPI.Client_Handle, FRI_TXT_WXID.Text);
|
||
}
|
||
//设置好友备注
|
||
void BUTTON_FRI_MARKClick(object sender, EventArgs e)
|
||
{
|
||
if(wxAPI.Client_Handle == 0)
|
||
MessageBox.Show("请选择一个操作账号!","错误");
|
||
else if(FRI_TXT_WXID.Text == "")
|
||
MessageBox.Show("请输入需要设置备注的好友Wxid!","错误");
|
||
else
|
||
{
|
||
string uMark = KstAPI.EnUnicode(FRI_TXT_MSG.Text);
|
||
wxAPI.Wx_SetMark(wxAPI.Client_Handle, FRI_TXT_WXID.Text, uMark);
|
||
}
|
||
}
|
||
//群聊邀请-直接拉群(批量)
|
||
void BUTTON_GROUP_INV_1Click(object sender, EventArgs e)
|
||
{
|
||
int c = FRIEND_LIST.CheckedItems.Count;
|
||
if(wxAPI.Client_Handle == 0)
|
||
MessageBox.Show("请选择一个操作账号!","错误");
|
||
else if(GROUP_TXT_GID.Text == "")
|
||
MessageBox.Show("请输入需要邀请的群ID!","错误");
|
||
else if(c < 1)
|
||
MessageBox.Show("请在好友列表框勾选需要邀请的好友","错误");
|
||
else
|
||
{
|
||
string[] Array_Wxid = new string[c];
|
||
for(int i=0;i<c;i++)
|
||
{
|
||
Array_Wxid.SetValue(FRIEND_LIST.CheckedItems[i].SubItems[2].Text, i);
|
||
}
|
||
wxAPI.WxGroup_Invite(wxAPI.Client_Handle, 1, GROUP_TXT_GID.Text, Array_Wxid);
|
||
}
|
||
}
|
||
//群聊邀请-邀请链接(批量)
|
||
void BUTTON_GROUP_INV_2Click(object sender, EventArgs e)
|
||
{
|
||
int c = FRIEND_LIST.CheckedItems.Count;
|
||
if(wxAPI.Client_Handle == 0)
|
||
MessageBox.Show("请选择一个操作账号!","错误");
|
||
else if(GROUP_TXT_GID.Text == "")
|
||
MessageBox.Show("请输入需要邀请的群ID!","错误");
|
||
else if(c < 1)
|
||
MessageBox.Show("请在好友列表框勾选需要邀请的好友","错误");
|
||
else
|
||
{
|
||
string[] Array_Wxid = new string[c];
|
||
for(int i=0;i<c;i++)
|
||
{
|
||
Array_Wxid.SetValue(FRIEND_LIST.CheckedItems[i].SubItems[2].Text, i);
|
||
}
|
||
wxAPI.WxGroup_Invite(wxAPI.Client_Handle, 2, GROUP_TXT_GID.Text, Array_Wxid);
|
||
}
|
||
}
|
||
|
||
//群聊踢人
|
||
void BUTTON_GROUP_KICKClick(object sender, EventArgs e)
|
||
{
|
||
if(wxAPI.Client_Handle == 0)
|
||
MessageBox.Show("请选择一个操作账号!","错误");
|
||
else if(GROUP_TXT_GID.Text == "")
|
||
MessageBox.Show("请输入需要踢人的群ID!","错误");
|
||
else if(GROUP_TXT_WXID.Text == "")
|
||
MessageBox.Show("请输入需要踢出的成员Wxid!","错误");
|
||
else
|
||
wxAPI.WxGroup_Kick(wxAPI.Client_Handle, GROUP_TXT_GID.Text, GROUP_TXT_WXID.Text);
|
||
}
|
||
//退群
|
||
void BUTTON_GROUP_EXITClick(object sender, EventArgs e)
|
||
{
|
||
if(wxAPI.Client_Handle == 0)
|
||
MessageBox.Show("请选择一个操作账号!","错误");
|
||
else if(GROUP_TXT_GID.Text == "")
|
||
MessageBox.Show("请输入需要退出的群ID!","错误");
|
||
else
|
||
wxAPI.WxGroup_Exit(wxAPI.Client_Handle, GROUP_TXT_GID.Text);
|
||
}
|
||
//改群名
|
||
void BUTTON_GROUP_SETNICKClick(object sender, EventArgs e)
|
||
{
|
||
if(wxAPI.Client_Handle == 0)
|
||
MessageBox.Show("请选择一个操作账号!","错误");
|
||
else if(GROUP_TXT_GID.Text == "")
|
||
MessageBox.Show("请输入需要操作的群ID!","错误");
|
||
else
|
||
{
|
||
string uNick = KstAPI.EnUnicode(GROUP_TXT_TEXT.Text);
|
||
wxAPI.WxGroup_SetNick(wxAPI.Client_Handle, GROUP_TXT_GID.Text, uNick);
|
||
}
|
||
|
||
}
|
||
//发群功能(群主功能,@所有人)
|
||
void BUTTON_GROUP_NOTICEClick(object sender, EventArgs e)
|
||
{
|
||
if(wxAPI.Client_Handle == 0)
|
||
MessageBox.Show("请选择一个操作账号!","错误");
|
||
else if(GROUP_TXT_GID.Text == "")
|
||
MessageBox.Show("请输入需要操作的群ID!","错误");
|
||
else if(GROUP_TXT_TEXT.Text == "")
|
||
MessageBox.Show("请输入需要发布的公告内容!","错误");
|
||
else
|
||
{
|
||
string uNotice = KstAPI.EnUnicode(GROUP_TXT_TEXT.Text);
|
||
wxAPI.WxGroup_SetNotice(wxAPI.Client_Handle, wxAPI.Client_Wxid, GROUP_TXT_GID.Text, uNotice);
|
||
}
|
||
|
||
}
|
||
//建群
|
||
void BUTTON_GROUP_CREATEClick(object sender, EventArgs e)
|
||
{
|
||
int c = FRIEND_LIST.CheckedItems.Count;
|
||
if(wxAPI.Client_Handle == 0)
|
||
MessageBox.Show("请选择一个操作账号!","错误");
|
||
else if(c < 2)
|
||
MessageBox.Show("请在好友列表框勾选2人以上","错误");
|
||
else if(c > 40)
|
||
MessageBox.Show("勾选不能超过40人","错误");
|
||
else
|
||
{
|
||
string[] Array_Wxid = new string[c];
|
||
for(int i=0;i<c;i++)
|
||
{
|
||
Array_Wxid.SetValue(FRIEND_LIST.CheckedItems[i].SubItems[2].Text, i);
|
||
}
|
||
wxAPI.WxGroup_Create(wxAPI.Client_Handle, Array_Wxid);
|
||
}
|
||
}
|
||
//防撤回
|
||
bool cis = false;
|
||
void CHK_REVOKECheckedChanged(object sender, EventArgs e)
|
||
{
|
||
if(cis == false)
|
||
{
|
||
if(wxAPI.Client_Handle == 0)
|
||
{
|
||
cis = true;
|
||
CHK_REVOKE.Checked = false;
|
||
MessageBox.Show("请选择一个操作账号!","错误");
|
||
}
|
||
else
|
||
{
|
||
wxAPI.Wx_DisRevoke(wxAPI.Client_Handle, Convert.ToInt32(CHK_REVOKE.Checked));
|
||
}
|
||
|
||
}
|
||
cis = false;
|
||
}
|
||
|
||
private void MainForm_Load(object sender, EventArgs e)
|
||
{
|
||
|
||
}
|
||
|
||
private void LOGIN_LIST_SelectedIndexChanged(object sender, EventArgs e)
|
||
{
|
||
|
||
}
|
||
}
|
||
}
|