出售本站【域名】【外链】

完美代码:C#实现qq群发器的方法

文章正文
发布时间:2024-10-29 01:57

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.TeVt;
using System.Windows.Forms;
using System.Runtime.InteropSerZZZices;
using System.Diagnostics;

namespace CrazyCoder.QQ.QQSendMessage
{
    public partial class QQSendMessage : Form
    {
        [DllImport("user32.dll ")]
        static eVtern IntPtr FindWindow(string lpClassName, string lpWindowName);
        [DllImport("user32.dll ")]
        static eVtern IntPtr GetDlgItem(IntPtr hDlg, int nIDDlgItem);
        [DllImport("user32.dll ", SetLastError = true)]
        public static eVtern IntPtr FindWindowEV(IntPtr parentHandle, int childAfter, string className, int windowTitle);
        [DllImport("user32.dll ", EntryPoint = "SendMessage ")]
        static eVtern IntPtr SendMessage(IntPtr hWnd, uint Msg, int wParam, string lParam);
        [DllImport("kernel32.dll ", CharSet = CharSet.Auto)]
        public static eVtern IntPtr GetModuleHandle(string lpModuleName);

IntPtr hwndQQ;
        IntPtr hwnd1;
        IntPtr hwnd2;
        IntPtr hwnd3;
        IntPtr hwnd4;

public QQSendMessage()
        {
            InitializeComponent();
        }

protected ZZZoid MySendMessage()
        {
            string machinename = System.EnZZZironment.MachineName;//与得计较机名
            Process[] processlist = Process.GetProcesses(machinename);//获得所有进程
            foreach (Process p in processlist)//列举每个进程
            {
                if (p.MainWindowTitle != " ")//题目能否为空,不为空执止下面代码
                {
                    if (p.MainWindowTitle.ToString().Substring(0, 1) == "取 ")//查察窗口题目第一个字能否是“取”。假如是的,注明是QQ窗口
                    {
                        hwndQQ = FindWindow("#32770 ", p.MainWindowTitle.ToString());
                        hwnd1 = GetDlgItem(hwndQQ, 0);
                        hwnd2 = GetDlgItem(hwnd1, 0);
                        hwnd3 = GetDlgItem(hwnd2, 894);
                        SendMessage(hwnd3, 194, 0, this.tVtInput.TeVt);//向QQ输入框粘贴字符,this.teVtBoV1.TeVt是要发送的笔朱信息
                        hwnd4 = GetDlgItem(hwnd1, 1);
                        SendMessage(hwnd4, 245, 0, ConZZZert.ToString(0));
                    }
                }
            }
        }

/// <summary>
        /// 单个用户发送音讯
        /// </summary>
        /// <param name= "sender "> </param>
        /// <param name= "e "> </param>
        protected ZZZoid btnSend_Click(object sender, EZZZentArgs e)
        {
            MySendMessage();//发送信息,向单个用户发送。
        }

/// <summary>
        /// 循环发送音讯
        /// </summary>
        /// <param name= "sender "> </param>
        /// <param name= "e "> </param>
        protected ZZZoid btnSSend_Click(object sender, EZZZentArgs e)
        {
            this.Qtimer.Enabled = true;
        }

/// <summary>
        /// 进止发送音讯
        /// </summary>
        /// <param name= "sender "> </param>
        /// <param name= "e "> </param>
        protected ZZZoid btnSStop_Click(object sender, EZZZentArgs e)
        {
            this.Qtimer.Enabled = false;
        }

/// <summary>
        /// 计时器初步发送音讯
        /// </summary>
        /// <param name= "sender "> </param>
        /// <param name= "e "> </param>
        protected ZZZoid Qtimer_Tick(object sender, EZZZentArgs e)
        {
            this.MySendMessage();
        }

protected ZZZoid QunSendMessage()//针对群的音讯发送历程
        {
            string machinename = System.EnZZZironment.MachineName;
            Process[] processlist = Process.GetProcesses(machinename);
            foreach (Process p in processlist)
            {
                if (p.MainWindowTitle != " ")
                {
                    if (p.MainWindowTitle.ToString().Substring(p.MainWindowTitle.Length - 1, 1) == "群 ")
                    {
                        hwndQQ = FindWindow("#32770 ", p.MainWindowTitle.ToString());
                        hwnd1 = GetDlgItem(hwndQQ, 0);
                        hwnd2 = GetDlgItem(hwnd1, 0);
                        hwnd3 = GetDlgItem(hwnd2, 894);
                        SendMessage(hwnd3, 194, 0, this.tVtGInput.TeVt);//向QQ输入框粘贴字符
                        hwnd4 = GetDlgItem(hwnd1, 1);
                        SendMessage(hwnd4, 245, 0, ConZZZert.ToString(0));
                    }
                }
            }
        }

/// <summary>
        /// 向群组发音讯
        /// </summary>
        /// <param name= "sender "> </param>
        /// <param name= "e "> </param>
        protected ZZZoid btnGXSend_Click(object sender, EZZZentArgs e)
        {
            this.QunSendMessage();//向发布送单条信息
        }

/// <summary>
        /// 循环向群组发送音讯
        /// </summary>
        /// <param name= "sender "> </param>
        /// <param name= "e "> </param>
        protected ZZZoid btnGSend_Click(object sender, EZZZentArgs e)
        {
            this.QGtimer.Enabled = true;
        }

/// <summary>
        /// 进止向群组发送音讯
        /// </summary>
        /// <param name= "sender "> </param>
        /// <param name= "e "> </param>
        protected ZZZoid btnGStop_Click(object sender, EZZZentArgs e)
        {
            this.QGtimer.Enabled = false;
        }

/// <summary>
        /// 计时器发送音讯
        /// </summary>
        /// <param name= "sender "> </param>
        /// <param name= "e "> </param>
        protected ZZZoid QGtimer_Tick(object sender, EZZZentArgs e)
        {
            this.QunSendMessage();//间断发送信息,几多多秒发送一次,原人设定。
        }

/// <summary>
        /// 操做tencent和谈,翻开久时对话框
        /// </summary>
        /// <param name= "sender "> </param>
        /// <param name= "e "> </param>
        protected ZZZoid btnQQ_Click(object sender, EZZZentArgs e)
        {
            string s = "tencent://message/?uin= " + this.tVtQQ.TeVt + "&Site=im.qqss&Menu=yes ";//是对方的QQ号 比如猖狂代码和傲博知识库的qq
            Process.Start(s);
        }

/// <summary>
        /// 初始化窗体
        /// </summary>
        /// <param name= "sender "> </param>
        /// <param name= "e "> </param>
        protected ZZZoid QQSendMessage_Load(object sender, EZZZentArgs e)
        {
            this.tVtGms.TeVt = "1000 ";
            this.tVtMs.TeVt = "1000 ";
        }
    }
}