示例#1
0
        public static BotWorker RegisterWorker(string connectionId, List <BotProcess> bots)
        {
            var worker = new BotWorker()
            {
                Processes    = bots,
                ConnectionId = connectionId,
                WorkerId     = Guid.NewGuid().ToString()
            };

            Workers.Add(worker);
            Console.WriteLine("New Worker Added... Worker Count: " + Workers.Count());
            return(worker);
        }
示例#2
0
        private void tmHotkey_Tick(object sender, EventArgs e)
        {
            // Text = $@"Num:{_num} || Step:{_step}";
            if (GetAsyncKeyState(Keys.NumPad1))
            {
                _num = 1;
            }
            else if (GetAsyncKeyState(Keys.NumPad2))
            {
                _num = 2;
            }
            else if (GetAsyncKeyState(Keys.NumPad3))
            {
                _num = 3;
            }
            else if (GetAsyncKeyState(Keys.NumPad4))
            {
                _num = 4;
            }
            else if (GetAsyncKeyState(Keys.NumPad5))
            {
                _num = 5;
            }
            else if (GetAsyncKeyState(Keys.NumPad6))
            {
                _num = 6;
            }
            else if (GetAsyncKeyState(Keys.NumPad7))
            {
                _num = 7;
            }
            else if (GetAsyncKeyState(Keys.NumPad8))
            {
                _num = 8;
            }
            else if (GetAsyncKeyState(Keys.NumPad9))
            {
                _num = 9;
            }

            if (BotWorker.IsBusy != true)
            {
                if (!BotWorker.CancellationPending)
                {
                    BotWorker.RunWorkerAsync();
                }
            }
        }
示例#3
0
        private void BotWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            if (_num == 0)
            {
                return;
            }

            _step = 1;

            if (_step != 1)
            {
                return;
            }
            var value = _num switch
            {
                1 => new Position(325, 280),
                2 => new Position(415, 280),
                3 => new Position(515, 280),
                4 => new Position(325, 350),
                5 => new Position(415, 350),
                6 => new Position(515, 350),
                7 => new Position(325, 420),
                8 => new Position(415, 420),
                9 => new Position(515, 420),
                _ => new Position()
            };

            Win32Bot.ClickInBg(Hayday, value.X, value.Y);
            Win32Bot.AwaitSleep(300);
            _step = 2;

            if (_step != 2)
            {
                return;
            }
            if (radMinAmount.Checked)
            {
                while (GetColor.GetColorFast(Hayday, 632, 298, 0xFFF8B0))
                {
                    Win32Bot.ClickInBg(Hayday, 632, 298);
                }
            }
            if (radMaxAmount.Checked)
            {
                while (GetColor.GetColorFast(Hayday, 791, 297, 0xFFF8B0))
                {
                    Win32Bot.ClickInBg(Hayday, 793, 300);
                }
            }

            Win32Bot.AwaitSleep(100);
            _step = 3;
            if (_step != 3)
            {
                return;
            }
            if (radMinPrice.Checked)
            {
                while (GetColor.GetColorFast(Hayday, 631, 387, 0xFFF8B0))
                {
                    Win32Bot.ClickInBg(Hayday, 677, 429);
                }
            }
            if (radMaxPrice.Checked)
            {
                while (GetColor.GetColorFast(Hayday, 789, 387, 0xFFF8B0))
                {
                    Win32Bot.ClickInBg(Hayday, 752, 429);
                }
            }

            Win32Bot.AwaitSleep(100);
            _step = 4;
            if (_step != 4)
            {
                return;
            }

            if (cbAutoSell.Checked)
            {
                Win32Bot.ClickInBg(Hayday, 707, 566);
            }

            _num  = 0;
            _step = 0;
            BotWorker.CancelAsync();
        }
    }