转帖 群发qq消息思路

最近弄了个淘宝想做个群发工具,查了一些资料 看到这个思路比较合理 就记下 以后查找方便

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
using System.Runtime.InteropServices;
using System.Diagnostics;
namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        [DllImport("user32.dll")]
        static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
        [DllImport("user32.dll")]
        static extern IntPtr GetDlgItem(IntPtr hDlg, int nIDDlgItem);
        [DllImport("user32.dll", SetLastError = true)]
        public static extern IntPtr FindWindowEx(IntPtr parentHandle, int childAfter, string className, int windowTitle);
        [DllImport("user32.dll", EntryPoint = "SendMessage")]
        static extern IntPtr SendMessage(IntPtr hWnd, uint Msg, int wParam, string lParam);
        [DllImport("kernel32.dll", CharSet = CharSet.Auto)]
        public static extern IntPtr GetModuleHandle(string lpModuleName);

 

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


        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
           
        }

        private void btnSend_Click(object sender, EventArgs e)
        {
            //try
            //{
            //    string s = "hello,  test";
            //    IntPtr itPr = (IntPtr)Convert.ToInt32(textBox2.Text.Trim(), 16);
            //    //SendMessage(this.textBox1.Handle, WM_SETTEXT, IntPtr.Zero, s);
            //    //MessageBox.Show();
            //    SendMessage(itPr, WM_SETTEXT, IntPtr.Zero, s);
            //    SendKeys.Send(Keys.Enter);
            //}
            //catch { }
            MySendMessage();//发送信息,向单个用户发送。
 

        }
         private void MySendMessage()
        {
            string machinename = System.Environment.MachineName;//获得计算机名
            Process[] processlist = Process.GetProcesses(machinename);//得到所有进程
            foreach (Process p in processlist)//列举每个进程
            {
                if (p.MainWindowTitle != "")//标题是否为空,不为空执行下面代码
                {
                    MessageBox.Show(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.textBox1.Text);//向QQ输入框粘贴字符,this.textBox1.Text是要发送的文字信息
                    //    hwnd4 = GetDlgItem(hwnd1, 1);
                    //    SendMessage(hwnd4, 245, 0, Convert.ToString(0));
                    //}
                }
            }
        }

 
    }

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值