protected override void Execute(NativeActivityContext context)
        {
            try
            {
                string sImagePath = ImagePath.Get(context);
                bool   result     = false;

                if (File.Exists(sImagePath))
                {
                    GetSetClick      getSetClick    = new GetSetClick();
                    ImageRecognition imgRecognition = new ImageRecognition();
                    getSetClick = GetSetClick.Click;
                    result      = imgRecognition.GetSetClickImage(sImagePath, getSetClick, "", 10000, Accuracy);
                    Result.Set(context, result);
                }
                //});
            }
            catch (Exception ex)
            {
                Logger.Log.Logger.LogData(ex.Message + " in activity Image_FindAndClick", Logger.LogLevel.Error);
                if (!ContinueOnError)
                {
                    context.Abort();
                }
            }
        }
Esempio n. 2
0
        public static void doLogic()
        {
            if (checkReconnect())
            {
                int reconnectTime = Settings.getInstance().reconnectTime;
                BotHelper.Log("Reconnect Button found. Pressing it in " + reconnectTime + " minutes.");

                int sleepTime = 0;
                if (reconnectTime != 0)
                {
                    sleepTime = reconnectTime * 1000 * 60;
                }
                else
                {
                    sleepTime = 5000; //wait 5 seconds anyways, just to be sure
                }
                System.Threading.Thread.Sleep(sleepTime);

                Point reconnectButton = ImageRecognition.getPictureLocation(Properties.Resources.button_reconnect, BotHelper.memu, 0.90f);
                ClickOnPointTool.ClickOnPoint(BotHelper.memu, ImageRecognition.getRandomLoc(reconnectButton, Properties.Resources.button_reconnect));

                BotHelper.Log("Reconnect Button pressed.");
            }
            else
            {
                BotHelper.Log("Reconnect Button check completed; Button not found.", true, true);
            }
        }
Esempio n. 3
0
        public static void openChest()
        {
            for (int i = 0; i < 16; i++)
            {
                // just to make sure it'll still be randomized...
                ADBHelper.simulateClick(new Point(rnd.Next(270 - 50, 270 + 50), rnd.Next(200 - 50, 200 + 50))); //Click anywhere to unbox
                BotHelper.randomDelay(200, 20);
            }

            ADBHelper.simulateClick(ImageRecognition.getRandomLoc(BotHelper.getResourceByName("button_collect_prizes"), 0.901f));

            // Check for Bonus item
            BotHelper.randomDelay(4000, 100); // it might take a second or two for the bonus chest to appear, better be safe than sorry
            comparePic = ADBHelper.getScreencap();
            Point bonusLabel = ImageRecognition.GetSubPositions(comparePic, BotHelper.getResourceByName("label_bonus")).FirstOrDefault();

            if (bonusLabel.X != 0 && bonusLabel.Y != 0)
            {
                // Bonus item, yay!
                Point watchButton = ImageRecognition.GetSubPositions(comparePic, BotHelper.getResourceByName("button_watch"), 0.901f).FirstOrDefault();
                if (watchButton.X != 0 && watchButton.Y != 0)
                {
                    // Ugh, they want us to watch an ad. Close the window.
                    Point closeButton = ImageRecognition.GetSubPositions(comparePic, BotHelper.getResourceByName("button_cancel"), 0.901f).FirstOrDefault();
                    ADBHelper.simulateClick(ImageRecognition.getRandomLoc(closeButton, BotHelper.getResourceByName("button_cancel")));
                }
                else
                {
                    ADBHelper.simulateClick(new Point(rnd.Next(270 - 50, 270 + 50), rnd.Next(200 - 50, 200 + 50))); //Click anywhere to unbox
                    BotHelper.randomDelay(300, 20);
                    ADBHelper.simulateClick(ImageRecognition.getRandomLoc(BotHelper.getResourceByName("button_collect_prizes"), 0.901f));
                }
            }
        }
Esempio n. 4
0
        public static bool checkForLeagueEnd()
        {
            // Does anything happen when you get put in a better league? Gonna have to test that.
            // If not, this should work already.

            Bitmap league_end_label = BotHelper.getResourceByName("label_league_over");

            Point labelPoint = ImageRecognition.getPictureLocation(comparePic, league_end_label);

            if (labelPoint != pNull)
            {
                // League ended. We gotta press "Claim" now and open that chest. :)
                BotHelper.randomDelay(1000, 100);

                Bitmap claimButton = BotHelper.getResourceByName("button_claim_onend");
                Point  claimPoint  = ImageRecognition.getPictureLocation(comparePic, claimButton);
                if (claimPoint != pNull)
                {
                    ADBHelper.simulateClick(claimPoint);
                    BotHelper.randomDelay(1000, 100);
                    ChestLogic.openChest();
                }
                else
                {
                    BotHelper.Log("Couldn't find claim button for leagueEnd. Returning to regular duty.");
                }

                return(true);
            }

            return(false);
        }
 protected override void Execute(NativeActivityContext context)
 {
     try
     {
         //ThreadInvoker.Instance.RunByUiThread(() =>
         //{
         string ScreenPath = ImagePath.Get(context);
         if ((ScreenPath != null) && (ScreenPath != string.Empty))
         {
             if (File.Exists(ScreenPath))
             {
                 string           sValue         = SetText.Get(context);
                 GetSetClick      getSetClick    = new GetSetClick();
                 ImageRecognition imgRecognition = new ImageRecognition();
                 getSetClick = GetSetClick.Set;
                 bool result = imgRecognition.GetSetClickImage(ScreenPath, getSetClick, sValue, 10000, accuracy);
                 Result.Set(context, result);
             }
         }
         //});
     }
     catch (Exception ex)
     {
         Logger.Log.Logger.LogData(ex.Message + " in activity Image_FindAndSetText", Logger.LogLevel.Error);
         if (!ContinueOnError)
         {
             context.Abort();
         }
     }
 }
Esempio n. 6
0
        public static void doLogic()
        {
            if (checkReconnect())
            {
                int reconnectTime = Settings.getInstance().reconnectTime;
                BotHelper.Log("Reconnect Button found. Pressing it in " + reconnectTime + " minutes.");

                int sleepTime = 0;
                if (reconnectTime != 0)
                {
                    sleepTime = reconnectTime * 1000 * 60;
                }
                else
                {
                    sleepTime = 5000; //wait 5 seconds anyways, just to be sure
                }
                System.Threading.Thread.Sleep(sleepTime);

                Bitmap button_reconnect = BotHelper.getResourceByName("button_reconnect");

                Point reconnectButton = ImageRecognition.getPictureLocation(button_reconnect, 0.90f);
                ADBHelper.simulateClick(ImageRecognition.getRandomLoc(reconnectButton, button_reconnect));

                BotHelper.Log("Reconnect Button pressed.");
            }
            else
            {
                BotHelper.Log("Reconnect Button check completed; Button not found.", true, true);
            }
        }
Esempio n. 7
0
        private static void openClosestChest()
        {
            Point closestChest = getClosestChest();

            // The sponsor chest is the smallest one, so we use this for our random location algorithm to make sure won't miss a chest
            ADBHelper.simulateClick(ImageRecognition.getRandomLoc(closestChest, BotHelper.getResourceByName("chest_sponsor")));
            BotHelper.randomDelay(5000, 50); // it takes some time to open a chest sometimes
            openChest();
        }
        public static void WaitForImage(string imagePath)
        {
            bool exists = ImageRecognition.ImageExists(imagePath);

            while (!exists)
            {
                exists = ImageRecognition.ImageExists(imagePath);
                Thread.Sleep(1000);
            }
        }
        public static void LeftClickImage(string image)
        {
            if (ImageRecognition.ImageExists(image))
            {
                Point coords = ImageRecognition.ImageCoords(image);

                Mouse.Move(coords.X, coords.Y);
                Mouse.PressButton(Mouse.MouseKeys.Left, 150);
            }
        }
Esempio n. 10
0
        private void T_Elapsed(object sender, ElapsedEventArgs e)
        {
            var coords = ImageRecognition.GetCoordinates(Properties.Resources.Accept_1920x1080);

            if (coords != null)
            {
                MouseController.MoveAndLeftClick(coords.X, coords.Y);
                MouseController.LeftClick();
            }
        }
Esempio n. 11
0
        //Check if we defended, if yes, click that filthy "Claim" button that's prevent us from clicking "QUICK FIGHT" ;)
        public static void checkDefense()
        {
            Helper.BotHelper.Log("Successful defense check");

            if (ImageRecognition.getPictureLocation(Properties.Resources.button_defend, BotHelper.memu) != pNull)
            {
                ClickOnPointTool.ClickOnPoint(BotHelper.memu, ImageRecognition.getRandomLoc(Properties.Resources.button_defend, BotHelper.memu));
                BotHelper.Log("Yup, we defended");
                BotHelper.randomDelay(1000, 100);
            }
        }
Esempio n. 12
0
        private static bool isChestUnlocking()
        {
            Point chestTimer = ImageRecognition.GetSubPositions(comparePic, BotHelper.getResourceByName("chest_unlock"), 0.891f).FirstOrDefault();

            if (chestTimer.X != 0 && chestTimer.Y != 0)
            {
                return(true);
            }

            return(false);
        }
Esempio n. 13
0
        private static bool chestsReady()
        {
            Point chestArrow = ImageRecognition.GetSubPositions(comparePic, BotHelper.getResourceByName("arrow_chest"), 0.791f).FirstOrDefault();

            if (chestArrow.X != 0 && chestArrow.Y != 0)
            {
                return(true);
            }

            return(false);
        }
Esempio n. 14
0
    private void Start()
    {
        _text = textMesh.GetComponent <TMPro.TextMeshProUGUI>();
        _arImageRecognition = _arSessionOrigin.GetComponent <ImageRecognition>();
        _arPlane            = _arSessionOrigin.GetComponent <ARPlaceObjects>();

        Switcher();

        button.GetComponentInChildren <TMPro.TextMeshProUGUI>().text = "Plane";
        switcher = true;
    }
Esempio n. 15
0
        //Wait for the client by detecting when the play button is displayed
        public void waitForConfirmButton()
        {
            bool normal = ImageRecognition.ImageExists("confirmNormal.png");
            bool hover  = ImageRecognition.ImageExists("confirmHover.png");

            while (!normal && !hover)
            {
                normal = ImageRecognition.ImageExists("confirmNormal.png");
                hover  = ImageRecognition.ImageExists("confirmHover.png");
                Thread.Sleep(1000);
            }
        }
Esempio n. 16
0
        private static bool checkReconnect()
        {
            Point reconnectButton = ImageRecognition.getPictureLocation(Properties.Resources.button_reconnect, BotHelper.memu, 0.90f);

            if (reconnectButton.X == 0 && reconnectButton.Y == 0)
            {
                return(false);
            }
            else
            {
                return(true);
            }
        }
Esempio n. 17
0
        public static void doLogic()
        {
            BotHelper.randomDelay(1000, 100); //make sure to screen is cleared from previous tasks, just in case. Will probably be removed after some testing.
            currentlyUnlocking = true;
            comparePic         = ImageRecognition.CaptureApplication();

            currentlyUnlocking = isChestUnlocking();

            if (chestsReady())
            {
                BotHelper.Log("Completed box found!");
                openClosestChest();
            }

            if (!currentlyUnlocking)
            {
                BotHelper.Log("There's no box being unlocked right now, unlocking");
                List <Point> regularBoxes = ImageRecognition.GetSubPositions(comparePic, BotHelper.getResourceByName("chest_regular"));
                List <Point> superBoxes   = ImageRecognition.GetSubPositions(comparePic, BotHelper.getResourceByName("chest_super"));

                Point firstReg = regularBoxes.FirstOrDefault();
                Point firstSup = superBoxes.FirstOrDefault();

                if (firstReg.X != 0 && firstReg.Y != 0)
                {
                    // Open a regular box
                    BotHelper.Log(" regular box", false);
                    ADBHelper.simulateClick(ImageRecognition.getRandomLoc(firstReg, BotHelper.getResourceByName("chest_regular")));
                    BotHelper.randomDelay(1000, 100);
                    ADBHelper.simulateClick(ImageRecognition.getRandomLoc(BotHelper.getResourceByName("button_unlock")));
                    BotHelper.randomDelay(1000, 100);
                    ADBHelper.simulateClick(ImageRecognition.getRandomLoc(BotHelper.getResourceByName("button_cancel"), 0.901f));
                }
                else if (firstSup.X != 0 && firstSup.Y != 0)
                {
                    // Open a super box
                    BotHelper.Log(" super box", false);
                    ADBHelper.simulateClick(ImageRecognition.getRandomLoc(firstSup, BotHelper.getResourceByName("chest_super")));
                    BotHelper.randomDelay(1000, 100);
                    ADBHelper.simulateClick(ImageRecognition.getRandomLoc(BotHelper.getResourceByName("button_unlock")));
                    BotHelper.randomDelay(1000, 100);
                    ADBHelper.simulateClick(ImageRecognition.getRandomLoc(BotHelper.getResourceByName("button_cancel"), 0.901f));
                }
                else
                {
                    BotHelper.Log(" ...nevermind. No boxes found.", false);
                }
            }

            BotHelper.Log("Finished ChestLogic!");
        }
Esempio n. 18
0
 public void clickConfirmButton()
 {
     if (ImageRecognition.ImageExists("confirmNormal.png"))
     {
         Point coords = ImageRecognition.ImageCoords("confirmNormal.png");
         Mouse.Move(coords.X + (PixelCache.GetWidth("confirmNormal.png") / 2), coords.Y + (PixelCache.GetHeight("confirmNormal.png") / 2));
         Mouse.PressButton(Mouse.MouseKeys.Left, 150);
     }
     else if (ImageRecognition.ImageExists("confirmHover.png"))
     {
         Point coords = ImageRecognition.ImageCoords("confirmHover.png");
         Mouse.Move(coords.X + (PixelCache.GetWidth("confirmHover.png") / 2), coords.Y + (PixelCache.GetHeight("confirmHover.png") / 2));
         Mouse.PressButton(Mouse.MouseKeys.Left, 150);
     }
 }
Esempio n. 19
0
        private static bool checkReconnect()
        {
            Bitmap button_reconnect = BotHelper.getResourceByName("button_reconnect");

            Point reconnectButton = ImageRecognition.getPictureLocation(button_reconnect, 0.90f);

            if (reconnectButton.X == 0 && reconnectButton.Y == 0)
            {
                return(false);
            }
            else
            {
                return(true);
            }
        }
Esempio n. 20
0
        // Check if we defended, if yes, click that filthy "Claim" button that's preventing us from clicking "QUICK FIGHT" ;)
        public static bool checkDefense()
        {
            Helper.BotHelper.Log("Successful defense check", true, true);
            Bitmap button_claim = BotHelper.getResourceByName("button_claim");
            Point  claimPoint   = ImageRecognition.getPictureLocation(button_claim);

            if (claimPoint != pNull)
            {
                ADBHelper.simulateClick(ImageRecognition.getRandomLoc(claimPoint, button_claim));
                BotHelper.Log("We defended. Free coins! :)");
                BotHelper.randomDelay(1200, 100);
                return(true);
            }
            return(false);
        }
Esempio n. 21
0
        // Check if somebody got an instant promotion, because that window will be blocking the bot even after a restart
        public static bool checkInstantPromo()
        {
            Bitmap button_ok = BotHelper.getResourceByName("button_ok");

            Helper.BotHelper.Log("Instant Promo Check", true, true);
            Point okPoint = ImageRecognition.getPictureLocation(comparePic, button_ok);

            if (okPoint != pNull)
            {
                ADBHelper.simulateClick(ImageRecognition.getRandomLoc(okPoint, button_ok));
                BotHelper.Log("Someone got instant promoted.");
                BotHelper.randomDelay(1200, 100);
                return(true);
            }
            return(false);
        }
Esempio n. 22
0
        //returns 1 for win, 2 for loss and 0 for error
        private static int checkWin()
        {
            Point win    = ImageRecognition.getPictureLocation(Properties.Resources.label_victory, BotHelper.memu);
            Point defeat = ImageRecognition.getPictureLocation(Properties.Resources.label_defeat, BotHelper.memu);

            if (win.X != 0 && win.Y != 0)
            {
                return(1);
            }
            else if (defeat.X != 0 && defeat.Y != 0)
            {
                return(2);
            }

            return(0);
        }
Esempio n. 23
0
        private static Point getClosestChest()
        {
            Point chestArrow = ImageRecognition.GetSubPositions(comparePic, BotHelper.getResourceByName("arrow_chest"), 0.791f).FirstOrDefault();

            List <Point> regularBoxes = ImageRecognition.GetSubPositions(comparePic, BotHelper.getResourceByName("chest_regular"));
            List <Point> superBoxes   = ImageRecognition.GetSubPositions(comparePic, BotHelper.getResourceByName("chest_super"));
            List <Point> sponsorBox   = ImageRecognition.GetSubPositions(comparePic, BotHelper.getResourceByName("chest_sponsor"));

            List <Point> allChests = new List <Point>();

            allChests.AddRange(regularBoxes);
            allChests.AddRange(superBoxes);
            allChests.AddRange(sponsorBox);

            // Return the closest chest that's below the arrow
            return(allChests.Where(pt => pt.Y > chestArrow.Y).GetClosestPoint(chestArrow));
        }
Esempio n. 24
0
 // Try to find the "Quick Fight" button and click on it.
 public static bool searchDuell()
 {
     BotHelper.Log("Attempting to press the Duell button");
     if (ImageRecognition.getPictureLocation(Properties.Resources.button_fight, BotHelper.memu) != pNull)
     {
         Point dbgPoint = ImageRecognition.getPictureLocation(Properties.Resources.button_fight, BotHelper.memu);
         BotHelper.Log("Button found! FeelsGoodMan.");
         BotHelper.Log("Button found at: X = " + dbgPoint.X + "; Y = " + dbgPoint.Y, true, true);
         ClickOnPointTool.ClickOnPoint(BotHelper.memu, ImageRecognition.getRandomLoc(Properties.Resources.button_fight, BotHelper.memu));
         return(true);
     }
     else
     {
         BotHelper.Log("Button not found! FeelsBadMan.");
         return(false);
     }
 }
Esempio n. 25
0
 public bool getConfirmButton()
 {
     if (ImageRecognition.ImageExists("confirmNormal.png"))
     {
         return(true);
     }
     else
     {
         if (ImageRecognition.ImageExists("confirmHover.png"))
         {
             return(true);
         }
         else
         {
             return(false);
         }
     }
 }
Esempio n. 26
0
        public static bool checkForChestInForeground()
        {
            Bitmap regChest = BotHelper.getResourceByName("label_regularbox");
            Bitmap supChest = BotHelper.getResourceByName("label_super_box");
            Bitmap legChest = BotHelper.getResourceByName("label_legendary_box");

            Point pRegChest = ImageRecognition.getPictureLocation(comparePic, regChest);
            Point pSupChest = ImageRecognition.getPictureLocation(comparePic, supChest);
            Point pLegChest = ImageRecognition.getPictureLocation(comparePic, legChest);

            if (pRegChest != pNull || pSupChest != pNull || pLegChest != pNull)
            {
                ChestLogic.openChest();
                return(true);
            }

            return(false);
        }
Esempio n. 27
0
        private void LoadImage(string name, bool keepSize = true)
        {
            Image resourceToGet = (Image)Properties.Resources.ResourceManager.GetObject(name + "_720");

            if (resourceToGet != null)
            {
                image = new Bitmap(resourceToGet);

                if (!keepSize)
                {
                    ImageRecognition.ResizeImage(ref image);
                    ButtonRectangle = new Rectangle(ButtonRectangle.X / 4, ButtonRectangle.Y / 4, ButtonRectangle.Width / 4, ButtonRectangle.Height / 4);
                }
                else
                {
                    image = image.Clone(new Rectangle(0, 0, image.Width, image.Height), System.Drawing.Imaging.PixelFormat.Format24bppRgb);
                }
            }
        }
Esempio n. 28
0
        //returns 1 for win, 2 for loss and 0 for error
        private static int checkWin()
        {
            Bitmap img           = ImageRecognition.CaptureApplication();
            Bitmap label_victory = BotHelper.getResourceByName("label_victory");
            Bitmap label_defeat  = BotHelper.getResourceByName("label_defeat");

            Point win    = ImageRecognition.GetSubPositions(img, label_victory).FirstOrDefault();
            Point defeat = ImageRecognition.GetSubPositions(img, label_defeat).FirstOrDefault();

            if (win.X != 0 && win.Y != 0)
            {
                return(1);
            }
            else if (defeat.X != 0 && defeat.Y != 0)
            {
                return(2);
            }

            return(0);
        }
Esempio n. 29
0
        //Check for the skip button. If it's there, an opponent has been found.
        public static bool waitDuell()
        {
            BotHelper.Log("Waiting for the duell to start....");
            int checks = 0;

            do
            {
                BotHelper.Log(" " + checks, false);
                Thread.Sleep(100);
                checks++;
            } while (ImageRecognition.getPictureLocation(Properties.Resources.button_skip, BotHelper.memu) == pNull && checks <= 55);

            if (checks >= 55)
            {
                BotHelper.Log("Oops, we timed out.");
                return(false);
            }

            BotHelper.randomDelay(500, 50);
            return(true);
        }
Esempio n. 30
0
        private void RecognitionTimer_Elapsed(object sender, ElapsedEventArgs e)
        {
            var coords = ImageRecognition.GetCoordinates(Properties.Resources.lockImage);

            if (coords != null)
            {
                StopVoid(true);
                MouseController.MoveAndLeftClick(Agent.SelectedAgent.X, Agent.SelectedAgent.Y);
                Thread.Sleep(10);
                for (int i = 0; i < 5; i++)
                {
                    MouseController.LeftClick();
                }
                MouseController.MoveAndLeftClick(coords.X, coords.Y);
                Thread.Sleep(10);
                for (int i = 0; i < 5; i++)
                {
                    MouseController.LeftClick();
                }
            }
        }
Esempio n. 31
0
        private void workbench_FeaturesTrained(object sender, ImageRecognition.FeaturesTrainedEventArgs e)
        {
            Logger.Inst.SetResult(e.TotalNumberOfTrials, e.LastNSuccessRate, e.FeatureCount,
                e.AverageAttractiveness, e.AverageInterestingness, e.AverageNumberOfPoints, e.AverageNumberOfDataSeen,
                e.MaxAttractiveness, e.MaxInterestingness);

            if (!UpdateStats) {
                return;
            }

            this.TotalNumberOfTrials = e.TotalNumberOfTrials;
            this.LastNSuccessRate = e.LastNSuccessRate;
            this.SuccessRatePerLabel = e.SuccessRatePerLabel;
            this.FeatureCount = e.FeatureCount;

            this.MaxSuccessRate = e.MaxSuccessRate;
            this.Monoticity = e.Monoticity;

            this.AverageAttractiveness = e.AverageAttractiveness;
            this.AverageInterestingness = e.AverageInterestingness;
            this.AverageNumberOfPoints = e.AverageNumberOfPoints;
            this.AverageNumberOfDataSeen = e.AverageNumberOfDataSeen;

            this.MaxInterestingness = e.MaxInterestingness;
            this.MaxAttractiveness = e.MaxAttractiveness;

            var now = DateTime.Now.TimeOfDay;
            this.TimeToUpdate = now.Subtract(this.LastUpdate);
            this.LastUpdate = now;
        }