Пример #1
0
        private void timerTyping_Tick(object sender, EventArgs e)
        {
            System.Text.StringBuilder title = new System.Text.StringBuilder(256);
            IntPtr handleWindow             = GetForegroundWindow();

            GetWindowText(handleWindow, title, title.Capacity);
            Status("รอเลือกหน้าจอเกม...");

            if (title.ToString().StartsWith("YGOnline"))
            {
                Status("บอทกำลังทำงาน...");
                //Bot
                SerialCode.GameWindow gameWindow = SerialCode.GameWindowList()[comboBoxGameWindow.SelectedIndex];
                _bot.Run(handleWindow, gameWindow, comboBoxNpcZoom.SelectedIndex == 0);
            }
            //Update Status
            UpdateStatus();

            //Stop bot
            if (_bot.BotStop)
            {
                Status("สิ้นสุดการทำงาน");
                Stop();
            }
        }
Пример #2
0
        private void FormMain_Load(object sender, EventArgs e)
        {
            //Set title
            this.Text = @"Yulgang Serial Code " + Assembly.GetExecutingAssembly().GetName().Version.ToString();

            //Set Bot
            _bot = new Bot();

            //Game Window
            foreach (SerialCode.GameWindow gameWindow in SerialCode.GameWindowList())
            {
                comboBoxGameWindow.Items.Add(gameWindow.Width.ToString() + "x" + gameWindow.Height.ToString());
            }

            comboBoxGameWindow.SelectedIndex = 0;
            comboBoxNpcZoom.SelectedIndex    = 0;
        }
Пример #3
0
        public void Run(IntPtr handleWindow, SerialCode.GameWindow gameWindow, Boolean npcZoom)
        {
            if (Running)
            {
                Console.WriteLine(@"Bot running...");
            }
            else
            {
                //set running
                Running = true;
                Console.WriteLine(@"Bot start...");
                Console.WriteLine(@"run index :" + _runIndex.ToString());

                //Check code
                if ((_runIndex + 1) > _codes.Length || _codes.Length == 0)
                {
                    Console.WriteLine(@"Bot set stop");

                    BotStop = true;
                    return;
                }

                //Get code
                string code  = _codes[_runIndex];
                string index = _indexes[_runIndex];
                Console.WriteLine(code);
                Console.WriteLine(index);

                //Set run code
                RunCode  = code;
                RunIndex = index;

                //Check code empty
                if (code == "" || code.Trim() == "" || code == " ")
                {
                    Console.WriteLine(@"Skip code empty");
                }
                else
                {
                    var serialCode = new SerialCode(handleWindow);

                    //Talk NPC
                    serialCode.NpcSelection();

                    //Sleep for NPC
                    if (npcZoom)
                    {
                        Thread.Sleep(2500);
                    }
                    else
                    {
                        Thread.Sleep(1000);
                    }

                    //Open window for put code
                    serialCode.OpenWindow(gameWindow);
                    Thread.Sleep(500);

                    //Typing code
                    serialCode.Code(code);
                    Thread.Sleep(500);

                    //Enter code
                    serialCode.Enter();

                    //Sleep for close NPC
                    if (npcZoom)
                    {
                        Thread.Sleep(1500);
                    }
                    else
                    {
                        Thread.Sleep(500);
                    }
                }

                _runIndex++;
                //Clear running
                Running = false;
            }
        }