当前位置:编程学习 > C#/ASP.NET >>

[Help]如何实现QQ在线和离线状态的切换?

RT,谢谢。。。 --------------------编程问答-------------------- 帮顶。。 --------------------编程问答-------------------- 我也想研究 --------------------编程问答-------------------- 有一种方法是  通过发送消息的方式

用spy++检测点击上线下线按钮时,什么hwnd收到了什么message,


namespace QQss
{

    
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
            bt_start_stop.Enabled = false;
        }

        [DllImport("user32.dll")]
        public static extern IntPtr PostMessage(IntPtr hwnd, int wMsg, IntPtr wParam, IntPtr lParam);
        [DllImport("user32.dll")]
        public static extern IntPtr FindWindowEx(IntPtr hwndParent, IntPtr hwndChildAfter, string lpszClass, string lpszWindow);
        
        static int state = 0;
        static IntPtr hwnd;
        static Message msg1;
        static Message msg2;
        static Message msg3;

        private void button1_Click(object sender, EventArgs e)
        {
            timer1.Enabled = !(timer1.Enabled);
            if (timer1.Enabled == true)
            {
                bt_start_stop.Text = "STOP";
            }
            else
            {
                bt_start_stop.Text = "START";
            }
        }       

        private void timer1_Tick(object sender, EventArgs e)
        {

            if (state % 3 == 0)
            {
                PostMessage(msg2.HWnd, msg2.Msg, msg2.WParam, msg2.LParam);
            }
            else
            {
                if (state % 3 == 1)
                {
                    PostMessage(msg1.HWnd, msg1.Msg, msg1.WParam, msg1.LParam);
                }
                else
                {                            
                    PostMessage(msg3.HWnd, msg3.Msg, msg3.WParam, msg3.LParam);
                }
            }
            state++;
            if (state > 60000)
            {
                state = 1;
            }
        }

        private void bt_set_Click(object sender, EventArgs e)
        {
            if (tbx_frq.Text == "")
            {
                MessageBox.Show("请输入间隔时间");
            }
            else
            {
                hwnd = FindWindowEx(IntPtr.Zero, IntPtr.Zero, "#32770", "");
                msg1 = Message.Create(hwnd, 273, new IntPtr(12493), IntPtr.Zero);
                msg2 = Message.Create(hwnd, 273, new IntPtr(12500), IntPtr.Zero);
                msg3 = Message.Create(hwnd, 273, new IntPtr(12507), IntPtr.Zero);
                timer1.Interval = Int32.Parse(tbx_frq.Text);
                bt_start_stop.Enabled = true;
            }
        }
    }
}



以前自己写的,有点简陋,设置间隔时间,能离线忙碌上线都可以


--------------------编程问答-------------------- 关注一下 --------------------编程问答-------------------- 如果使用QQ2008的话,
在线和离线状态反复切换,
不会要求输入验证码吧?
补充:.NET技术 ,  C#
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,