Пример #1
0
        private void BackgroundWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            for (int i = 0; i < 400; i++)
            {
                if (BackgroundWorker.CancellationPending)
                {
                    e.Cancel = true;

                    return;
                }
                System.Threading.Thread.Sleep(10);
            }

            TibiaImageReader tibiaImageReader = new TibiaImageReader();
            AddItem          addItem          = new AddItem();

            List <Item> items = addItem.GetAllItems();
            ulong       spent = 0;

            foreach (Item item in items)
            {
                if (BackgroundWorker.CancellationPending || spent >= NumericUpDownMaxSpent.Value)
                {
                    if (BackgroundWorker.CancellationPending)
                    {
                        e.Cancel = true;
                    }

                    return;
                }

                MouseSimulator.MoveMouseTo((double)SearchTextPosition.X / Screen.PrimaryScreen.Bounds.Width * ushort.MaxValue, (double)SearchTextPosition.Y / Screen.PrimaryScreen.Bounds.Height * ushort.MaxValue);
                MouseSimulator.LeftButtonClick();
                System.Threading.Thread.Sleep(150);
                KeyboardSimulator.ModifiedKeyStroke(WindowsInput.Native.VirtualKeyCode.CONTROL, WindowsInput.Native.VirtualKeyCode.VK_A);
                System.Threading.Thread.Sleep(150);
                KeyboardSimulator.TextEntry(item.Name);
                System.Threading.Thread.Sleep((int)NumericUpDownDelayToRiskOperations.Value);
                MouseSimulator.MoveMouseTo((double)FirstItemPosition.X / Screen.PrimaryScreen.Bounds.Width * ushort.MaxValue, (double)FirstItemPosition.Y / Screen.PrimaryScreen.Bounds.Height * ushort.MaxValue);
                MouseSimulator.LeftButtonDoubleClick();
                System.Threading.Thread.Sleep((int)NumericUpDownDelayToRiskOperations.Value);

                try
                {
                    while (true)
                    {
                        if (BackgroundWorker.CancellationPending || spent >= NumericUpDownMaxSpent.Value)
                        {
                            if (BackgroundWorker.CancellationPending)
                            {
                                e.Cancel = true;
                            }

                            return;
                        }

                        uint marketValue = tibiaImageReader.GetValueOfCurrentItem(FirstValuePositionTop, FirstValuePositionBottom);

                        if (IsToBuy(item.Value, marketValue) && (!CheckBoxMonitored.Checked || MessageBox.Show("Pode comprar? Item: " + item.Name + " Valor: " + item.Value, "", MessageBoxButtons.YesNo) == DialogResult.Yes) && marketValue + spent <= NumericUpDownMaxSpent.Value)
                        {
                            uint quantyToBuy = (uint)(NumericUpDownMaxSpent.Value - spent) / marketValue;
                            uint quantyIsBuy = Math.Min(quantyToBuy, tibiaImageReader.GetValueOfCurrentItem(FirstCountPositionTop, FirstCountPositionBottom));

                            for (int i = 1; i < quantyIsBuy; i++)
                            {
                                MouseSimulator.MoveMouseTo((double)ChangeCountPosition.X / Screen.PrimaryScreen.Bounds.Width * ushort.MaxValue, (double)ChangeCountPosition.Y / Screen.PrimaryScreen.Bounds.Height * ushort.MaxValue);
                                System.Threading.Thread.Sleep(100);
                                MouseSimulator.LeftButtonClick();

                                TextBoxSpent.Text  = uint.Parse(TextBoxSpent.Text) + marketValue + "";
                                TextBoxProfit.Text = uint.Parse(TextBoxProfit.Text) + item.Value - marketValue + "";
                            }

                            MouseSimulator.MoveMouseTo((double)AcceptButtonPosition.X / Screen.PrimaryScreen.Bounds.Width * ushort.MaxValue, (double)AcceptButtonPosition.Y / Screen.PrimaryScreen.Bounds.Height * ushort.MaxValue);
                            System.Threading.Thread.Sleep(50);
                            MouseSimulator.LeftButtonClick();

                            spent             += quantyIsBuy * marketValue;
                            TextBoxSpent.Text  = uint.Parse(TextBoxSpent.Text) + marketValue + "";
                            TextBoxProfit.Text = uint.Parse(TextBoxProfit.Text) + item.Value - marketValue + "";
                        }
                        else
                        {
                            break;
                        }

                        System.Threading.Thread.Sleep((int)NumericUpDownDelayToRiskOperations.Value);
                    }
                }
                catch { }
            }
        }
Пример #2
0
        private void AdicionarItemToolStripMenuItem_Click(object sender, EventArgs e)
        {
            AddItem addItem = new AddItem();

            addItem.ShowDialog();
        }