// Selects an option in the slot menu.
 internal bool SelectMenuOption(Point point)
 {
     cg.Cursor = point; // Select the option
     Thread.Sleep(100);
     // <image url="$(ProjectDir)\ImageComments\Interact.cs\OptionSelect.png" scale="0.7" />
     cg.updateScreen();
     if (cg.CompareColor(point.X, point.Y, new int[] { 83, 133, 155 }, 20)) // Detects if the blue color of the selected option is there, clicks then returns true
     {
         cg.LeftClick(point.X, point.Y, 0);
         cg.ResetMouse();
         return(true);
     }
     return(false);
 }
Example #2
0
 /// <summary>
 /// Send message to chat.
 /// </summary>
 /// <param name="text">Text to send.</param>
 public void Chat(string text)
 {
     if (ChatPrefix != null)
     {
         text = ChatPrefix + " " + text;
     }
     //if (!cg.OpenChatIsDefault)
     OpenChat();
     cg.updateScreen();
     // To prevent abuse, make sure that the channel is not general.
     if (!cg.CompareColor(ChatLocation.X, ChatLocation.Y, GeneralChatColor, 20) || !BlockGeneralChat)
     {
         cg.TextInput(text);
     }
     cg.KeyPress(Keys.Return);
     if (cg.OpenChatIsDefault)
     {
         Thread.Sleep(250);
         OpenChat();
     }
     cg.ResetMouse();
 }
Example #3
0
 /// <summary>
 /// Changes who can join.
 /// </summary>
 /// <param name="setting">Join setting to select.</param>
 public void SetJoinSetting(Join setting)
 {
     cg.LeftClick(280, 198);
     if (setting == Join.Everyone)
     {
         cg.LeftClick(280, 220);                           // Click "Everyone"
     }
     if (setting == Join.FriendsOnly)
     {
         cg.LeftClick(280, 240);                              // Click "Friends Only"
     }
     if (setting == Join.InviteOnly)
     {
         cg.LeftClick(280, 260);                             // Click "Invite Only"
     }
     cg.ResetMouse();
 }
Example #4
0
            /// <summary>
            /// Add AI to the game.
            /// </summary>
            /// <param name="hero">Hero type to add.</param>
            /// <param name="difficulty">Difficulty of hero.</param>
            /// <param name="team">Team that AI joins.</param>
            /// <param name="count">Amount of AI that is added. Set to -1 for max. Default is -1</param>
            /// <returns></returns>
            public bool AddAI(AIHero hero, Difficulty difficulty, BotTeam team, int count = -1)
            {
                cg.updateScreen();

                // Find the maximum amount of bots that can be placed on a team, and store it in the maxBots variable

                if (cg.DoesAddButtonExist())

                /*
                 * If the blue shade of the "Move" button is there, that means that the Add AI button is there.
                 * If the Add AI button is missing, we can't add AI, so return false. If it is there, add the bots.
                 * The AI button will be missing if the server is full
                 */
                {
                    // Open AddAI menu.
                    cg.Cursor = new Point(835, 182);
                    cg.WaitForUpdate(835, 182, 20, 2000);
                    cg.LeftClick(835, 182, 500);

                    List <Keys> press = new List <Keys>();

                    if (hero != AIHero.Recommended)
                    {
                        press.Add(Keys.Space);
                        int heroid = (int)hero;
                        for (int i = 0; i < heroid; i++)
                        {
                            press.Add(Keys.Down);
                        }
                        press.Add(Keys.Space);
                        press.Add(Keys.Down);
                    }

                    press.Add(Keys.Down);

                    if (difficulty != Difficulty.Easy)
                    {
                        press.Add(Keys.Space);
                        int difficultyID = (int)difficulty;
                        for (int i = 0; i < difficultyID; i++)
                        {
                            press.Add(Keys.Down);
                        }
                        press.Add(Keys.Space);
                        press.Add(Keys.Down);
                        press.Add(Keys.Down);
                    }

                    press.Add(Keys.Down);
                    press.Add(Keys.Down);

                    if (team != BotTeam.Both)
                    {
                        press.Add(Keys.Space);
                        int teamID = (int)team;
                        for (int i = 0; i < teamID; i++)
                        {
                            press.Add(Keys.Down);
                        }
                        press.Add(Keys.Space);
                        press.Add(Keys.Down);
                        press.Add(Keys.Down);
                        press.Add(Keys.Down);
                        press.Add(Keys.Down);
                    }

                    if (count > 0)
                    {
                        press.Add(Keys.Up);
                        for (int i = 0; i < 12; i++)
                        {
                            press.Add(Keys.Left);
                        }
                        for (int i = 0; i < count; i++)
                        {
                            press.Add(Keys.Right);
                        }
                        press.Add(Keys.Down);
                    }

                    press.Add(Keys.Down);
                    press.Add(Keys.Space);

                    cg.KeyPress(press.ToArray());

                    cg.ResetMouse();

                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            /// <summary>
            /// Loads a preset saved in Overwatch, 0 being the first saved preset.
            /// </summary>
            /// <param name="preset">Preset to load.</param>
            /// <param name="maxWaitTime">Maximum time to wait for the preset to show up.</param>
            // Loads a preset in Overwatch Custom Games
            public bool LoadPreset(int preset, int maxWaitTime = 5000)
            {
                if (preset < 0)
                {
                    throw new ArgumentOutOfRangeException("preset", preset, "Argument preset must be equal or greater than 0.");
                }

                Point presetLocation = GetPresetLocation(preset);

                cg.GoToSettings();
                cg.LeftClick(103, 183, 2000); // Clicks "Preset" button

                Stopwatch wait = new Stopwatch();

                wait.Start();

                if (numPresets == null)
                {
                    while (true)
                    {
                        cg.updateScreen();

                        if (cg.CompareColor(presetLocation.X, presetLocation.Y, new int[] { 126, 128, 134 }, 40))
                        {
                            break;
                        }
                        else if (wait.ElapsedMilliseconds >= maxWaitTime)
                        {
                            cg.GoBack(2);
                            cg.ResetMouse();
                            return(false);
                        }

                        Thread.Sleep(100);
                    }
                }
                else
                {
                    Point finalPresetLocation = GetPresetLocation(numPresets);
                    while (true)
                    {
                        cg.updateScreen();

                        if (cg.CompareColor(finalPresetLocation.X, finalPresetLocation.Y, new int[] { 126, 128, 134 }, 40))
                        {
                            break;
                        }
                        else if (wait.ElapsedMilliseconds >= maxWaitTime)
                        {
                            cg.GoBack(2);
                            cg.ResetMouse();
                            return(false);
                        }

                        Thread.Sleep(100);
                    }
                }

                Thread.Sleep(250);

                cg.LeftClick(presetLocation.X, presetLocation.Y); // Clicks the preset
                cg.LeftClick(480, 327);                           // Clicks confirm

                // Go back to lobby
                cg.GoBack(2);
                cg.ResetMouse();
                return(true);
            }
Example #6
0
            public void MenuOptionMarkup(int slot, int max, int savestart = 0, string savelocation = null)
            {
                if (slot < 0 || slot > Queueid + 5)
                {
                    throw new InvalidSlotException(string.Format("Slot argument '{0}' is out of range.", slot));
                }

                Point slotlocation = FindSlotLocation(slot);

                if (slotlocation.IsEmpty)
                {
                    return;
                }
                OpenSlotMenu(slotlocation);

                if (savelocation == null)
                {
                    savelocation = @"C:\Users\" + Environment.UserName + @"\Documents\Abyxa\Library\";
                }

                // Get direction opened menu is going.
                Direction dir = Getmenudirection(slotlocation);

                int[] offset = OffsetViaDirection(dir);

                int xstart        = slotlocation.X + 14, // X position to start scanning
                    xmax          = 79,                  // How far on the X axis to scan
                    ystart        = 0,                   // Y position to start scanning
                    ymax          = 6;                   // How far on the Y axis to scan.
                double yincrement = 0;                   // Amount to increment to scan next option line

                if (dir == Direction.RightDown)
                {
                    ystart     = slotlocation.Y + 12;
                    yincrement = 11.5;
                }
                else if (dir == Direction.RightUp)
                {
                    ystart     = slotlocation.Y - 128;
                    yincrement = -11.5;
                }

                cg.updateScreen();
                // Scan -the number of the variable max- lines.
                for (int mi = 0, yii = ystart; mi < max; mi++, yii = ystart + (int)(yincrement * (mi))) // Mi is the line to scan, yii is the Y coordinate of line mi.
                {
                    // Get bitmap of option
                    Bitmap work = cg.BmpClone(xstart, yii, xmax, ymax);

                    for (int xi = 0; xi < work.Width; xi++)
                    {
                        for (int yi = 0; yi < work.Height; yi++)
                        {
                            int   fade      = 80;
                            int[] textcolor = new int[] { 169, 169, 169 };
                            if (work.CompareColor(xi, yi, textcolor, fade))
                            {
                                work.SetPixel(xi, yi, Color.Black);
                            }
                            else
                            {
                                work.SetPixel(xi, yi, Color.White);
                            }
                        }
                    }
                    work.Save(savelocation + "markup-" + (mi + savestart).ToString() + ".png");
                    work.Dispose();
                }

                // Close the menu.
                cg.LeftClick(400, 500, 100);
                cg.LeftClick(500, 500, 100);
                cg.ResetMouse();
            }