Esempio n. 1
0
        public static void LoginQQ(string qq, string pwd, Form2 form2)
        {
            int    pid     = QqProcessDictionary[qq];
            IntPtr hIntPtr = IntPtr.Zero;
            var    t       = DateTime.Now;

            while (hIntPtr == IntPtr.Zero)
            {
                hIntPtr = FindWindow("CQUI", "酷Q 5.11.10A (180130)");
                if (DateTime.Now - t > new TimeSpan(0, 0, 10))
                {
                    break;
                }
            }

            MoveWindow(hIntPtr, -1000, -1000, 500, 400, true);
            ShowWindow(hIntPtr, SW_RESTORE);
            SetForegroundWindow(hIntPtr);
            Thread.Sleep(50);
            SendMessage(hIntPtr, WM_SYSKEYDOWN, 0X09, 0);
            Thread.Sleep(50);
            SendMessage(hIntPtr, WM_SYSKEYDOWN, 0X09, 0);
            Thread.Sleep(50);
            InputStr(hIntPtr, qq);
            Thread.Sleep(50);
            SendMessage(hIntPtr, WM_SYSKEYDOWN, 0X09, 0);
            Thread.Sleep(50);
            InputStr(hIntPtr, pwd);
            Thread.Sleep(50);
            SendMessage(hIntPtr, WM_SYSKEYDOWN, 0X09, 0);
            Thread.Sleep(50);
            SendMessage(hIntPtr, WM_SYSKEYDOWN, 0X0D, 0);
            Thread.Sleep(50);
            SendMessage(hIntPtr, WM_SYSKEYUP, 0X0D, 0);
            Thread.Sleep(3000);
            hIntPtr = FindWindow("CQUI", "酷Q 5.11.10A (180130)");
            if (hIntPtr != IntPtr.Zero)
            {
                var p = Process.GetProcessById(pid);
                hIntPtr = FindWindow(null, "错误");
                if (hIntPtr != IntPtr.Zero)
                {
                    form2.UpdateStatusDesc(qq, "账号或密码错误");
                }
                else
                {
                    hIntPtr = FindWindow(null, "登录验证");
                    if (hIntPtr != IntPtr.Zero)
                    {
                        form2.UpdateStatusDesc(qq, "设备锁限制");
                    }
                    else
                    {
                        DateTime start = DateTime.Now;
                        while (false)
                        {
                            if (DateTime.Now - start >= new TimeSpan(0, 1, 0))
                            {
                                break;
                            }
                            // TODO:需要修改
                            hIntPtr = FindWindow(null, "登陆验证");
                            if (hIntPtr == IntPtr.Zero)
                            {
                                Thread.Sleep(1000);
                            }
                            else
                            {
                                hIntPtr = FindWindow("CQUI", "酷Q 5.11.10A (180130)");
                                if (hIntPtr == IntPtr.Zero)
                                {
                                    form2.UpdateStatusDesc(qq, "登陆成功");

                                    return;
                                }
                                else
                                {
                                    break;
                                }
                            }
                        }
                        form2.UpdateStatusDesc(qq, "其他错误");
                    }
                }


                if (p != null)
                {
                    p.Kill();
                    p.Close();
                }
                QqProcessDictionary.TryRemove(qq, out pid);
            }
            else
            {
                // 登陆成功
                form2.UpdateStatusDesc(qq, "登陆成功");
            }
        }