基本信息
源码名称:QQ的消息发送功能
源码大小:0.12M
文件格式:.rar
开发语言:C#
更新时间:2015-12-24
   友情提示:(无需注册或充值,赞助后即可获取资源下载链接)

     嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):813200300

本次赞助数额为: 2 元 
   源码介绍

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace QQAutoMsg
{
    /// <summary>
    /// 消息发送器的UI主窗体
    /// </summary>
    public partial class FormAutoMsg : Form
    {
        public FormAutoMsg()
        {
            InitializeComponent();
        }

        /// <summary>
        /// 链接网址的linklabel的CLICK事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void lnkWebSite_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            ////打开真有意思网
            System.Diagnostics.Process.Start("http://www.zu14.cn/");
        }

        /// <summary>
        /// 停止按钮的响应事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnStop_Click(object sender, EventArgs e)
        {
            ////停止定时器
            this.tmrAutoMsg.Stop();

            ////改变按钮状态
            this.btnDo.Enabled = true;
            this.btnStop.Enabled = false;
        }

        /// <summary>
        /// 定时器的tick事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void tmrAutoMsg_Tick(object sender, EventArgs e)
        {
            ////停止定时器
            this.tmrAutoMsg.Stop();

            ////发送消息
            try
            {
                DoSend(this.tbMsg.Text);
            }
            finally ////最终再开启定时器
            {
                this.tmrAutoMsg.Start();
            }
        }

        /// <summary>
        /// 启动按钮的响应事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnDo_Click(object sender, EventArgs e)
        {
            ////设置 timer 的 interval 值
            this.tmrAutoMsg.Interval = Convert.ToInt32(this.nudSendInterval.Value) * 1000;

            ////改变按钮状态
            this.btnDo.Enabled = false;
            this.btnStop.Enabled = true;
            ////发送消息
            DoSend(this.tbMsg.Text);
            ////启动定时器
            this.tmrAutoMsg.Start();
        }

        /// <summary>
        /// 发送消息,支持N条内容随机/滚动发送(未共享,有需要请自行实现)
        /// </summary>
        /// <param name="msg">要发送的消息内容,最长255个字符</param>
        private static void DoSend(string msg)
        {
            ////获取所有已打开的QQ聊天窗口
            List<EnumQQChatWindows.QQChatWindow> qqChatWindows = EnumQQChatWindows.Windows;

            if (qqChatWindows.Count == 0) //如果未打开任何聊天窗口,给予提示信息
            {
                MessageBox.Show("当前未打开任何QQ聊天窗口!", "提醒", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }

            ////向所有已打开的窗口发送消息
            QQMsgSender.Go(qqChatWindows, msg);
        }

        /// <summary>
        /// 双击文本框,清空其内容
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void tbMsg_DoubleClick(object sender, EventArgs e)
        {
            this.tbMsg.Clear();
        }
    }
}