Exemplo n.º 1
0
        public void StartSorting(Tab unsortedTab, Tab sortedTab)
        {
            ApplicationHelper.OpenPathOfExile();
            List <Item> unsortedItems = unsortedTab.Items.Where(x => sortedTab.Items.Any(c => c.Id == x.Id && c.X == x.X && x.Y == c.Y) == false).ToList();

            if (isSorting == false)
            {
                GetStashDimentions();
                isSorting = true;

                Item unsortedItem = unsortedItems.FirstOrDefault();

                if (unsortedItem != null)
                {
                    MouseTools.MoveCursor(MouseTools.GetMousePosition(), new Vector2(startPos.X + unsortedItem.X * cellWidth, startPos.Y + unsortedItem.Y * cellHeight), 20);

                    bool selectGem = true;


                    while (unsortedItem != null)
                    {
                        if (interrupt == true)
                        {
                            interrupt = false;
                            break;
                        }
                        Item sortedItem = sortedTab.Items.FirstOrDefault(x => x.Id == unsortedItem.Id);

                        Vector2 unsortedPos = new Vector2(startPos.X + unsortedItem.X * cellWidth, startPos.Y + unsortedItem.Y * cellHeight);

                        if (selectGem)
                        {
                            //Move to item
                            MouseTools.MoveCursor(MouseTools.GetMousePosition(), unsortedPos, 10);
                            //select item
                            MouseTools.MouseClickEvent();
                            //wait a little (internet delay)
                            Thread.Sleep((int)(80f / Settings.Instance.Speed));
                        }

                        Vector2 sortedPos = new Vector2(startPos.X + sortedItem.X * cellWidth, startPos.Y + sortedItem.Y * cellHeight);

                        //Log.Message("Moving " + unsortedItem.Name + " from " + unsortedItem.X + "," + unsortedItem.Y + " to " + sortedItem.X + "," + sortedItem.Y);

                        //move to correct position
                        MouseTools.MoveCursor(MouseTools.GetMousePosition(), sortedPos, 10);
                        //place item
                        MouseTools.MouseClickEvent();
                        //wait a little (internet delay)
                        Thread.Sleep((int)(80f / Settings.Instance.Speed));

                        Item newGem = unsortedItems.FirstOrDefault(x => x.X == sortedItem.X && x.Y == sortedItem.Y);

                        //remove unsorted now that it is sorted
                        unsortedItems.Remove(unsortedItem);

                        //if there wassent a item where the item was placed
                        if (newGem == null)
                        {
                            //selected a new to sort
                            unsortedItem = unsortedItems.FirstOrDefault();
                            selectGem    = true;
                        }
                        else
                        {
                            unsortedItem = newGem;
                            selectGem    = false;
                        }
                    }
                }
                //Log.Message("Sorting Complete");
            }
            isSorting = false;
        }
Exemplo n.º 2
0
 public static void MouseClickEvent()
 {
     MouseTools.MouseEvent(MouseTools.MouseEventFlags.LeftDown);
     Thread.Sleep(70);
     MouseTools.MouseEvent(MouseTools.MouseEventFlags.LeftUp);
 }