⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 qqhk.cs

📁 把QQ群里的消息记录下来
💻 CS
字号:
/* ************************************************************************
 * 描述: 主窗口
 * 创建: sodak 2006-12-30
 *   
 *					 开 发 历 史 
 * ------------------------------------------------------------------------
 *  
 * 修改日期     修 改 内 容          修改人
 * ------------------------------------------------------------------------
 * 
 * 
 *****************************************************************************/
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Configuration;

namespace TQQ
{
	/// <summary>
	/// 主窗口
	/// </summary>
	public class QQhk : System.Windows.Forms.Form
	{
		private System.Windows.Forms.Button button1;
		private System.Windows.Forms.ListBox lbGroupMsgList1;
		private System.Windows.Forms.ListBox lbGroupMsgList2;
		private System.Windows.Forms.Button btnSend;
		private System.Windows.Forms.TextBox txtSend;
		private System.Windows.Forms.Timer tmGetMsg;
		private System.Windows.Forms.TextBox txtGroupWinName1;
		private System.Windows.Forms.TextBox txtGroupWinName2;
		private System.Windows.Forms.TextBox txtGroupWinName3;
		private System.Windows.Forms.ListBox lbGroupMsgList3;
		private System.Windows.Forms.Label label1;
		private System.Windows.Forms.Label label2;
		private System.Windows.Forms.Label label3;
		private System.Windows.Forms.Label label4;
		private System.ComponentModel.IContainer components;

		public QQhk()
		{
			InitializeComponent();
		}

		/// <summary>
		/// 清理所有正在使用的资源。
		/// </summary>
		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if(components != null)
				{
					components.Dispose();
				}
			}
			base.Dispose( disposing );
		}

		#region Windows 窗体设计器生成的代码
		/// <summary>
		/// 设计器支持所需的方法 - 不要使用代码编辑器修改
		/// 此方法的内容。
		/// </summary>
		private void InitializeComponent()
		{
			this.components = new System.ComponentModel.Container();
			this.lbGroupMsgList1 = new System.Windows.Forms.ListBox();
			this.lbGroupMsgList2 = new System.Windows.Forms.ListBox();
			this.button1 = new System.Windows.Forms.Button();
			this.btnSend = new System.Windows.Forms.Button();
			this.txtGroupWinName1 = new System.Windows.Forms.TextBox();
			this.txtSend = new System.Windows.Forms.TextBox();
			this.tmGetMsg = new System.Windows.Forms.Timer(this.components);
			this.txtGroupWinName2 = new System.Windows.Forms.TextBox();
			this.txtGroupWinName3 = new System.Windows.Forms.TextBox();
			this.lbGroupMsgList3 = new System.Windows.Forms.ListBox();
			this.label1 = new System.Windows.Forms.Label();
			this.label2 = new System.Windows.Forms.Label();
			this.label3 = new System.Windows.Forms.Label();
			this.label4 = new System.Windows.Forms.Label();
			this.SuspendLayout();
			// 
			// lbGroupMsgList1
			// 
			this.lbGroupMsgList1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
			this.lbGroupMsgList1.ItemHeight = 12;
			this.lbGroupMsgList1.Location = new System.Drawing.Point(32, 40);
			this.lbGroupMsgList1.Name = "lbGroupMsgList1";
			this.lbGroupMsgList1.Size = new System.Drawing.Size(752, 134);
			this.lbGroupMsgList1.TabIndex = 0;
			// 
			// lbGroupMsgList2
			// 
			this.lbGroupMsgList2.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
			this.lbGroupMsgList2.ItemHeight = 12;
			this.lbGroupMsgList2.Location = new System.Drawing.Point(32, 200);
			this.lbGroupMsgList2.Name = "lbGroupMsgList2";
			this.lbGroupMsgList2.Size = new System.Drawing.Size(752, 134);
			this.lbGroupMsgList2.TabIndex = 1;
			// 
			// button1
			// 
			this.button1.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
			this.button1.Location = new System.Drawing.Point(32, 512);
			this.button1.Name = "button1";
			this.button1.TabIndex = 2;
			this.button1.Text = "开始";
			this.button1.Click += new System.EventHandler(this.button1_Click);
			// 
			// btnSend
			// 
			this.btnSend.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
			this.btnSend.Location = new System.Drawing.Point(712, 512);
			this.btnSend.Name = "btnSend";
			this.btnSend.TabIndex = 3;
			this.btnSend.Text = "发送";
			this.btnSend.Click += new System.EventHandler(this.btnSend_Click);
			// 
			// txtGroupWinName1
			// 
			this.txtGroupWinName1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
			this.txtGroupWinName1.Location = new System.Drawing.Point(88, 16);
			this.txtGroupWinName1.Name = "txtGroupWinName1";
			this.txtGroupWinName1.Size = new System.Drawing.Size(224, 21);
			this.txtGroupWinName1.TabIndex = 4;
			this.txtGroupWinName1.Text = "校友群1 - 高级群";
			// 
			// txtSend
			// 
			this.txtSend.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
			this.txtSend.Location = new System.Drawing.Point(384, 514);
			this.txtSend.Name = "txtSend";
			this.txtSend.Size = new System.Drawing.Size(320, 21);
			this.txtSend.TabIndex = 5;
			this.txtSend.Text = "";
			// 
			// tmGetMsg
			// 
			this.tmGetMsg.Interval = 1000;
			this.tmGetMsg.Tick += new System.EventHandler(this.tmGetMsg_Tick);
			// 
			// txtGroupWinName2
			// 
			this.txtGroupWinName2.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
			this.txtGroupWinName2.Location = new System.Drawing.Point(88, 176);
			this.txtGroupWinName2.Name = "txtGroupWinName2";
			this.txtGroupWinName2.Size = new System.Drawing.Size(232, 21);
			this.txtGroupWinName2.TabIndex = 6;
			this.txtGroupWinName2.Text = "校友群2 - 群";
			// 
			// txtGroupWinName3
			// 
			this.txtGroupWinName3.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
			this.txtGroupWinName3.Location = new System.Drawing.Point(88, 338);
			this.txtGroupWinName3.Name = "txtGroupWinName3";
			this.txtGroupWinName3.Size = new System.Drawing.Size(232, 21);
			this.txtGroupWinName3.TabIndex = 6;
			this.txtGroupWinName3.Text = "校友群3 - 群";
			// 
			// lbGroupMsgList3
			// 
			this.lbGroupMsgList3.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
			this.lbGroupMsgList3.ItemHeight = 12;
			this.lbGroupMsgList3.Location = new System.Drawing.Point(32, 362);
			this.lbGroupMsgList3.Name = "lbGroupMsgList3";
			this.lbGroupMsgList3.Size = new System.Drawing.Size(752, 134);
			this.lbGroupMsgList3.TabIndex = 1;
			// 
			// label1
			// 
			this.label1.Location = new System.Drawing.Point(312, 518);
			this.label1.Name = "label1";
			this.label1.Size = new System.Drawing.Size(64, 16);
			this.label1.TabIndex = 7;
			this.label1.Text = "发送消息";
			// 
			// label2
			// 
			this.label2.Location = new System.Drawing.Point(32, 340);
			this.label2.Name = "label2";
			this.label2.Size = new System.Drawing.Size(48, 16);
			this.label2.TabIndex = 8;
			this.label2.Text = "第3个群";
			// 
			// label3
			// 
			this.label3.Location = new System.Drawing.Point(32, 179);
			this.label3.Name = "label3";
			this.label3.Size = new System.Drawing.Size(55, 16);
			this.label3.TabIndex = 9;
			this.label3.Text = "第2个群";
			// 
			// label4
			// 
			this.label4.Location = new System.Drawing.Point(32, 19);
			this.label4.Name = "label4";
			this.label4.Size = new System.Drawing.Size(52, 16);
			this.label4.TabIndex = 10;
			this.label4.Text = "第1个群";
			// 
			// QQhk
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
			this.ClientSize = new System.Drawing.Size(802, 543);
			this.Controls.Add(this.label4);
			this.Controls.Add(this.label3);
			this.Controls.Add(this.label2);
			this.Controls.Add(this.label1);
			this.Controls.Add(this.txtGroupWinName2);
			this.Controls.Add(this.txtSend);
			this.Controls.Add(this.txtGroupWinName1);
			this.Controls.Add(this.txtGroupWinName3);
			this.Controls.Add(this.btnSend);
			this.Controls.Add(this.button1);
			this.Controls.Add(this.lbGroupMsgList2);
			this.Controls.Add(this.lbGroupMsgList1);
			this.Controls.Add(this.lbGroupMsgList3);
			this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
			this.Name = "QQhk";
			this.Text = "QQ机器人";
			this.Load += new System.EventHandler(this.QQhk_Load);
			this.ResumeLayout(false);

		}
		#endregion

		private void button1_Click(object sender, System.EventArgs e)
		{
			//设置开始/暂停
			tmGetMsg.Enabled =  !tmGetMsg.Enabled;
			button1.Text = tmGetMsg.Enabled ? "暂停" : "开始";
		}

		private void btnSend_Click(object sender, System.EventArgs e)
		{
			//发送消息
			QQHooks.SendMsg(txtGroupWinName1.Text,txtSend.Text);
			QQHooks.SendMsg(txtGroupWinName2.Text,txtSend.Text);
			QQHooks.SendMsg(txtGroupWinName3.Text,txtSend.Text);
			txtSend.Text = string.Empty;
		}

		/// <summary>
		/// 时钟事件
		/// </summary>
		/// <param name="sender"></param>
		/// <param name="e"></param>
		private void tmGetMsg_Tick(object sender, System.EventArgs e)
		{
			//群1里的消息
			string strMsg = QQHooks.GetMsg(txtGroupWinName1.Text);		
			string str = "";
			
			if(!string.Empty.Equals(strMsg))
			{
				ArrayList msgList = ParseMsg.Parse(strMsg);

				foreach(QQMsg msg in msgList)
				{
					if(ConfigurationSettings.AppSettings["QQNum"] == msg.Number.ToString())continue;
					
					if(string.Empty.Equals(msg.Msg.Trim()))
						str =  string.Format("{0}在群1里做了个表情\r\n",msg.Name,msg.Msg);
					else
						 str =  string.Format("{0}在群1里说:\r\n{1}\r\n",msg.Name,msg.Msg);
					
					lbGroupMsgList1.Items.Add(str);
					//save msg 
					
					//发送消息
					QQHooks.SendMsg(txtGroupWinName2.Text,str);
					QQHooks.SendMsg(txtGroupWinName3.Text,str);
					
				}				
			}

			//群2里的消息
			strMsg = QQHooks.GetMsg(txtGroupWinName2.Text);	

			if(!string.Empty.Equals(strMsg))
			{
				ArrayList msgList = ParseMsg.Parse(strMsg);

				foreach(QQMsg msg in msgList)
				{
					if(ConfigurationSettings.AppSettings["QQNum"] == msg.Number.ToString())continue;

					if(string.Empty.Equals(msg.Msg.Trim()))
						str = string.Format("{0}在群2里做了个表情\r\n",msg.Name,msg.Msg);
					else
						str = string.Format("{0}在群2里说:\r\n{1}\r\n",msg.Name,msg.Msg);
					//save msg 
					
					lbGroupMsgList2.Items.Add(str);

					//发送消息
					QQHooks.SendMsg(txtGroupWinName1.Text,str);
					QQHooks.SendMsg(txtGroupWinName3.Text,str);
				}				
			}

			//群3里的消息
			strMsg = QQHooks.GetMsg(txtGroupWinName3.Text);	

			if(!string.Empty.Equals(strMsg))
			{
				ArrayList msgList = ParseMsg.Parse(strMsg);

				foreach(QQMsg msg in msgList)
				{
					if(ConfigurationSettings.AppSettings["QQNum"] == msg.Number.ToString())continue;

					if(string.Empty.Equals(msg.Msg.Trim()))
						str = string.Format("{0}在群3里做了个表情\r\n",msg.Name,msg.Msg);
					else
						str = string.Format("{0}在群3里说:\r\n{1}\r\n",msg.Name,msg.Msg);
					//save msg 
					
					lbGroupMsgList3.Items.Add(str);

					//发送消息
					QQHooks.SendMsg(txtGroupWinName1.Text,str);
					QQHooks.SendMsg(txtGroupWinName2.Text,str);
				}				
			}
		}

		private void QQhk_Load(object sender, System.EventArgs e)
		{
		
		}
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -