private void btnImage2_Click(object sender, EventArgs e)
        {
            //if (string.IsNullOrEmpty(Image2Path) == false && File.Exists(Image2Path) == true)
            //{
            //    pct2.Image = null;
            //    File.Delete(Image2Path);
            //}

            Image2Path = Globals.Temp_Dir + "\\" + AppProcess.TakeSceenshot(string.Format("sec{0}.jpg", imgcnt));
            //pct2.Image = null;
            pct2.Image = new Bitmap(Image2Path);
            imgcnt++;
            //pct2.Refresh();
        }
Example #2
0
        private void bwOpenGame_DoWork(object sender, DoWorkEventArgs e)
        {
            AppProcess.CloseGame();
            System.Threading.Thread.Sleep(2000);
            AppProcess.OpenGame();
            System.Threading.Thread.Sleep(10000);

            string fileName     = "";
            string testImageTwo = "";

            int  cnt           = 0;
            bool whileLoopExit = false;

            while (true)
            {
                if (cnt > 5)
                {
                    break;
                }

                System.Threading.Thread.Sleep(500);
                fileName = AppProcess.TakeSceenshot();
                System.Threading.Thread.Sleep(1000);

                //System.Threading.Timer TheTimer1 = null;
                //int t1 = 0;
                //TheTimer1 = new System.Threading.Timer((ot) =>
                //{
                //    try
                //    {
                //        TheTimer1.Dispose();
                //    }
                //    catch (Exception ex)
                //    {
                //        if (TheTimer1 != null)
                //            TheTimer1.Dispose();
                //    }

                //}, null, 1000, 100);


                testImageTwo = Globals.Temp_Dir + "\\" + fileName;


                if (ImageComparer.CompareImages(Globals.WarWindow1Image, testImageTwo, Globals.AForgeConfig.CompareLevel, Globals.Temp_Dir,
                                                Globals.AForgeConfig.SimilarityThreshold) == true)
                {
                    AppProcess.Tap(new Point(740, 660));
                    continue;
                }
                else if (ImageComparer.CompareImages(Globals.WarWindow11Image, testImageTwo, Globals.AForgeConfig.CompareLevel, Globals.Temp_Dir, Globals.AForgeConfig.SimilarityThreshold) == true)
                {
                    AppProcess.Tap(new Point(740, 660));
                    continue;
                }

                else if (ImageComparer.CompareImages(Globals.WarWindow2Image, testImageTwo, Globals.AForgeConfig.CompareLevel, Globals.Temp_Dir, Globals.AForgeConfig.SimilarityThreshold) == true)
                {
                    AppProcess.Tap(new Point(740, 630));
                    continue;
                }



                if (ImageComparer.CompareImages(Globals.PrestigeRewardsClaimImage, testImageTwo, Globals.AForgeConfig.CompareLevel, Globals.Temp_Dir, Globals.AForgeConfig.SimilarityThreshold) == true)
                {
                    AppProcess.Tap(new Point(860, 620));
                    continue;
                }

                if (ImageComparer.CompareImages(Globals.StartGamePrestigeRewardsClaimImage, testImageTwo, Globals.AForgeConfig.CompareLevel, Globals.Temp_Dir, Globals.AForgeConfig.SimilarityThreshold) == true)
                {
                    AppProcess.Tap(new Point(740, 620));
                    continue;
                }


                if (ImageComparer.CompareImages(Globals.FirstScene1Image, testImageTwo, Globals.AForgeConfig.CompareLevel - 0.1, Globals.Temp_Dir, Globals.AForgeConfig.SimilarityThreshold) == true)
                {
                    break;
                }


                else
                {
                    AppProcess.SendKey(AndroidKeys.KEYCODE_BACK);
                }

                cnt++;

                deleteFiles();
            }

            if (whileLoopExit == true)
            {
                fileName     = AppProcess.TakeSceenshot();
                testImageTwo = Globals.Temp_Dir + "\\" + fileName;
                if (ImageComparer.CompareImages(Globals.ExitImage, testImageTwo, Globals.AForgeConfig.CompareLevel + 0.01, Globals.Temp_Dir, Globals.AForgeConfig.SimilarityThreshold) == true)
                {
                    AppProcess.SendKey(AndroidKeys.KEYCODE_BACK);
                }
                deleteFiles();
            }


            AppProcess.Swipe(new Point(1200, 700), new Point(100, 0), 500);
        }
Example #3
0
        private void bwPlayAndWatchAds_DoWork(object sender, DoWorkEventArgs e)
        {
            int    sleepTime    = 0;
            string msg          = "";
            string fileName     = "";
            string testImageTwo = "";

            if (AppProcess.isAppRunning() == false)
            {
                Globals.AppNotRunningInARow++;
                return;
            }



            if (AppProcess.isAdActivity() == true)
            {
                if (ToAddAsWatched == true)
                {
                    Globals.WatchedAds++;
                    Globals.NoOffersInARow     = 0;
                    ToAddAsWatched             = false;
                    Globals.LoadingTriesInARow = 0;
                    Globals.ElseInARow         = 0;
                    startDate = DateTime.Now;
                }

                AppProcess.Wait();
                Globals.ElseInARow++;
                sleepTime = 2000;

                msg = DateTime.Now + " " + "else 2000 diffs : " + DateTime.Now.Subtract(startDate).Seconds + "";
                Globals.MainLogs.Add(msg);


                System.Threading.Thread.Sleep(2000);

                if (DateTime.Now.Subtract(startDate).Seconds > 35)
                {
                    fileName     = AppProcess.TakeSceenshot();
                    testImageTwo = Globals.Temp_Dir + "\\" + fileName;
                    System.Drawing.Image imageOne;
                    using (var bmpTemp = new Bitmap(testImageTwo))
                    {
                        imageOne = new Bitmap(bmpTemp);
                    }

                    if (imageOne.Size.Width == Globals.ScreenSize.Height)
                    {
                        AppProcess.Tap(new Point(650, 50));
                        //AppProcess.Tap(ConfigReader.GetPoint("touch", "no-close-issue-port"));
                    }
                    else
                    {
                        AppProcess.Tap(new Point(1360, 50));
                        //AppProcess.Tap(ConfigReader.GetPoint("touch", "no-close-issue-land"));
                    }

                    Globals.ElseInARow = 0;
                    msg = DateTime.Now + " " + "tap close button 0000";
                    Logger.WriteLog(msg);
                    Globals.MainLogs.Add(msg);
                    //return;
                }
            }
            else
            {
                fileName = AppProcess.TakeSceenshot();
                //System.Threading.Thread.Sleep(1000);
                //System.Threading.Timer TheTimer1 = null;
                //int t1 = 0;
                //TheTimer1 = new System.Threading.Timer((ot) =>
                //{
                //    try
                //    {
                //        TheTimer1.Dispose();
                //    }
                //    catch (Exception ex)
                //    {
                //        if (TheTimer1 != null)
                //            TheTimer1.Dispose();
                //    }

                //}, null, 1000, 100);
                testImageTwo = Globals.Temp_Dir + "\\" + fileName;
                //System.Threading.Thread.Sleep(1000);
                if (ImageComparer.CompareImages(Globals.OfferImage, testImageTwo, Globals.AForgeConfig.CompareLevel, Globals.Temp_Dir, Globals.AForgeConfig.SimilarityThreshold) == true)
                {
                    ToAddAsWatched = true;
                    AppProcess.RunOffer();
                    int time = random.Next(10000, 20000);
                    sleepTime = time;
                    msg       = DateTime.Now + " offers " + time;
                    Globals.MainLogs.Add(msg);
                }
                else if (ImageComparer.CompareImages(Globals.NoOfferImage, testImageTwo, Globals.AForgeConfig.CompareLevel + 0.01, Globals.Temp_Dir, Globals.AForgeConfig.SimilarityThreshold) == true)
                {
                    Globals.NoOffersInARow++;
                    Globals.LoadingTriesInARow = 0;
                    Globals.ElseInARow         = 0;
                    AppProcess.CloseNoOfferWindow();
                    sleepTime = 2000;
                    msg       = DateTime.Now + " " + "no offer 2000";
                    Globals.MainLogs.Add(msg);
                }
                else if (ImageComparer.CompareImages(Globals.LoadingImage, testImageTwo, Globals.AForgeConfig.CompareLevel, Globals.Temp_Dir, Globals.AForgeConfig.SimilarityThreshold) == true)
                {
                    Globals.LoadingTriesInARow++;
                    Globals.ElseInARow = 0;

                    sleepTime = 2000;
                    msg       = DateTime.Now + " " + "loading 2000";
                    Globals.MainLogs.Add(msg);
                }
                else if (ImageComparer.CompareImages(Globals.EndOfferImage, testImageTwo, Globals.AForgeConfig.CompareLevel + 0.03, Globals.Temp_Dir, Globals.AForgeConfig.SimilarityThreshold) == true)
                {
                    Globals.NoOffersInARow     = 0;
                    Globals.LoadingTriesInARow = 0;
                    Globals.ElseInARow         = 0;
                    //Globals.WatchedAds++;
                    sleepTime = 1000;
                    msg       = DateTime.Now + " " + "end of offer 1000";
                    Globals.MainLogs.Add(msg);
                    AppProcess.CloseEndOfOfferWindow();
                }
                else if (ImageComparer.CompareImages(Globals.IntroImage, testImageTwo, Globals.AForgeConfig.CompareLevel, Globals.Temp_Dir, Globals.AForgeConfig.SimilarityThreshold) == true)
                {
                    Globals.NoOffersInARow     = 0;
                    Globals.LoadingTriesInARow = 0;
                    Globals.ElseInARow         = 0;
                    //Globals.WatchedAds++;
                    sleepTime = 1000;
                    msg       = DateTime.Now + " " + "crashed 1000";
                    Globals.MainLogs.Add(msg);
                    Globals.GameCrashed = true;
                }

                else if (ImageComparer.CompareImages(Globals.PrepareImage, testImageTwo, Globals.AForgeConfig.CompareLevel - 0.10, Globals.Temp_Dir, Globals.AForgeConfig.SimilarityThreshold) == true)
                {
                    AppProcess.OpenOffersWindow();
                    sleepTime = 1000;
                    msg       = DateTime.Now + " " + "prepare 1000";
                    Globals.MainLogs.Add(msg);
                }
                else if (ImageComparer.CompareImages(Globals.PrestigeRewardsImage, testImageTwo, Globals.AForgeConfig.CompareLevel, Globals.Temp_Dir, Globals.AForgeConfig.SimilarityThreshold) == true)
                {
                    //AppProcess.Tap(ConfigReader.GetPoint("touch", "pr-rewards"));
                    AppProcess.Tap(new Point(740, 500));
                    System.Threading.Thread.Sleep(500);
                    //AppProcess.Tap(ConfigReader.GetPoint("touch", "pr-rewards"));
                    AppProcess.Tap(new Point(740, 500));
                    sleepTime = 1000;
                    msg       = DateTime.Now + " " + "prestige rewards 1000";
                    Globals.MainLogs.Add(msg);
                }
                else if (ImageComparer.CompareImages(Globals.PrestigeRewardsClaimImage, testImageTwo, Globals.AForgeConfig.CompareLevel, Globals.Temp_Dir, Globals.AForgeConfig.SimilarityThreshold) == true)
                {
                    //AppProcess.Tap(ConfigReader.GetPoint("touch", "pr-rewards-claim"));
                    AppProcess.Tap(new Point(860, 620));
                    sleepTime = 1000;
                    msg       = DateTime.Now + " " + "prestige rewards claim 1000";
                    Globals.MainLogs.Add(msg);
                }
                else if (ImageComparer.CompareImages(Globals.WarWindow1Image, testImageTwo, Globals.AForgeConfig.CompareLevel, Globals.Temp_Dir, Globals.AForgeConfig.SimilarityThreshold) == true)
                {
                    //AppProcess.Tap(ConfigReader.GetPoint("touch", "war-window-1"));
                    AppProcess.Tap(new Point(740, 660));
                    sleepTime = 1000;
                    msg       = DateTime.Now + " " + "war window 1 1000";
                    Globals.MainLogs.Add(msg);
                }
                else if (ImageComparer.CompareImages(Globals.WarWindow2Image, testImageTwo, Globals.AForgeConfig.CompareLevel, Globals.Temp_Dir, Globals.AForgeConfig.SimilarityThreshold) == true)
                {
                    AppProcess.Tap(ConfigReader.GetPoint("touch", "war-window-2"));
                    //AppProcess.Tap(new Point(740, 630));
                    sleepTime = 1000;
                    msg       = DateTime.Now + " " + "war window 2 1000";
                    Globals.MainLogs.Add(msg);
                }
                else if (ImageComparer.CompareImages(Globals.FirstScene1Image, testImageTwo, Globals.AForgeConfig.CompareLevel - 0.1, Globals.Temp_Dir,
                                                     Globals.AForgeConfig.SimilarityThreshold) == true)
                {
                    AppProcess.Swipe(new Point(1200, 700), new Point(100, 0), 500);
                    sleepTime = 1000;
                    msg       = DateTime.Now + " " + "first screen 1 1000";
                    Globals.MainLogs.Add(msg);
                }
                else if (ImageComparer.CompareImages(Globals.FirstScene2Image, testImageTwo, Globals.AForgeConfig.CompareLevel - 0.1, Globals.Temp_Dir,
                                                     Globals.AForgeConfig.SimilarityThreshold) == true)
                {
                    AppProcess.Swipe(new Point(1200, 700), new Point(100, 0), 500);
                    sleepTime = 1000;
                    msg       = DateTime.Now + " " + "first screen 2 1000";
                    Globals.MainLogs.Add(msg);
                }
                else
                {
                    AppProcess.Wait();
                    Globals.ElseInARow++;
                    sleepTime = 2000;
                    msg       = DateTime.Now + " " + "else 2000";
                    Globals.MainLogs.Add(msg);
                }
            }



            //if (Globals.ElseInARow > 20)
            //{
            //    System.Drawing.Image imageOne;
            //    using (var bmpTemp = new Bitmap(testImageTwo))
            //    {
            //        imageOne = new Bitmap(bmpTemp);
            //    }

            //    if (imageOne.Size.Width == Globals.ScreenSize.Height)
            //    {
            //        AppProcess.Tap(new Point(650, 50));
            //    }
            //    else
            //    {
            //        AppProcess.Tap(new Point(1360, 50));
            //    }

            //    Globals.ElseInARow = 0;
            //    Logger.WriteLog(DateTime.Now + " " + "tap close button 0000");
            //    //return;
            //}
            //System.Threading.Thread.Sleep(sleepTime);



            //System.Threading.Timer TheTimer = null;
            //int t = 0;
            //TheTimer = new System.Threading.Timer((ot) =>
            //{
            //    try
            //    {
            //        TheTimer.Dispose();
            //    }
            //    catch (Exception ex)
            //    {
            //        if (TheTimer != null)
            //            TheTimer.Dispose();

            //    }


            //}, null, sleepTime, 1000);

            Logger.WriteLog(msg);

            deleteFiles();
        }