コード例 #1
0
 private void button3_Click(object sender, EventArgs e)
 {
     PacketService.sendPacket(Process.GetProcessById(procId).Handle, procId, GoldService.RefreshListPacket());
 }
コード例 #2
0
        private void StartNewWindow()
        {
            while (File.Exists("lock.lock"))
            {
                Thread.Sleep(5000);
            }

            // файл уникальности
            File.Create("lock.lock").Close();



            Form1.procId = 0;
            String name = "elementclient";

            Process [] pwProceses = Process.GetProcessesByName(name);

            int [] pwProcessIdArray = new int [pwProceses.Length];

            int count = 0;

            foreach (Process pwProcess in pwProceses)
            {
                pwProcessIdArray [count] = pwProcess.Id;
                count++;
            }

            while (true)
            {
                try {
                    AppService.Start(Form1.textServerBox);
                    break;
                } catch (WebException) {
                    Thread.Sleep(5000);
                }
            }

            while (Form1.procId == 0)
            {
                Thread.Sleep(2000);

                Process [] pwProceses2 = Process.GetProcessesByName(name);

                foreach (Process pwProcess in pwProceses2)
                {
                    if (pwProcessIdArray.Contains(pwProcess.Id))
                    {
                        continue;
                    }

                    Form1.procId = pwProcess.Id;

                    break;
                }
            }



            Thread.Sleep(20000);

            ReadMemoryService.ActiveServerList(Process.GetProcessById(Form1.procId).Handle);

            // escape для выбора сервера
            PostMessage(Process.GetProcessById(Form1.procId).MainWindowHandle, WM_KEYDOWN, VK_ESCAPE, 0);
            Thread.Sleep(100);
            PostMessage(Process.GetProcessById(Form1.procId).MainWindowHandle, WM_KEYUP, VK_ESCAPE, 0);

            // удаляем файл
            File.Delete("lock.lock");

            Thread.Sleep(10000);

            // enter для входа
            PostMessage(Process.GetProcessById(Form1.procId).MainWindowHandle, WM_KEYDOWN, VK_ENTER, 0);
            Thread.Sleep(100);
            PostMessage(Process.GetProcessById(Form1.procId).MainWindowHandle, WM_KEYUP, VK_ENTER, 0);
            Thread.Sleep(1000);
            PostMessage(Process.GetProcessById(Form1.procId).MainWindowHandle, WM_KEYDOWN, VK_ENTER, 0);
            Thread.Sleep(100);
            PostMessage(Process.GetProcessById(Form1.procId).MainWindowHandle, WM_KEYUP, VK_ENTER, 0);

            Thread.Sleep(30000);

            string userName = ReadMemoryService.getPersName(Process.GetProcessById(Form1.procId).Handle);


            if (userName == "")
            {
                Form1.runThread.Abort();
            }

            changeName(userName, Form1.textServerBox);
            // замена title окна
            SetWindowText(Process.GetProcessById(Form1.procId).MainWindowHandle, userName + " (" + Form1.textServerBox + ")");

            // выбор аукциониста
            PacketService.sendPacket(Process.GetProcessById(Form1.procId).Handle, Form1.procId, GoldService.selectedNPC);

            while (ReadMemoryService.isLock(Process.GetProcessById(Form1.procId).Handle))
            {
                if (ReadMemoryService.getActiveWinName(Process.GetProcessById(Form1.procId).Handle) == "MsgBox_LinkBroken")
                {
                    Form1.runThread.Abort();
                }

                Thread.Sleep(1000);
            }

            Thread.Sleep(1000);
            PacketService.sendPacket(Process.GetProcessById(Form1.procId).Handle, Form1.procId, GoldService.selectedNPCMenu);
            Thread.Sleep(1000);
            PacketService.sendPacket(Process.GetProcessById(Form1.procId).Handle, Form1.procId, GoldService.RefreshListPacket());
        }