Пример #1
0
 public void FullScreenCaptureTest()
 {
     //ExtBitmap.ExtBitmap ebBkgrd = new ExtBitmap.ExtBitmap();
     //using (Chrono chrono = new Chrono("Full screen capture with ExtBitmap in Background mode"))
     //{
     //	chrono.Success = ebBkgrd.SnapShot(true);
     //	Assert.IsTrue(chrono.Success==true, "Full Screen capture failed with ExtBitmap in background mode (normal: PrintScrint doesn't work in full screen)");
     //	if (chrono.Success==true)
     //		chrono.Comment = string.Format("Size {0}x{1}", ebBkgrd.Width, ebBkgrd.Height);
     //}
     ExtBitmap.ExtBitmap ebNoBkgrd = new ExtBitmap.ExtBitmap();
     using (Chrono chrono = new Chrono("Full screen capture with ExtBitmap NOT in Background mode"))
     {
         chrono.Success = ebNoBkgrd.SnapShot(false);
         Assert.IsTrue(chrono.Success == true);
         if (chrono.Success == true)
         {
             chrono.Comment = string.Format("Size {0}x{1}", ebNoBkgrd.Width, ebNoBkgrd.Height);
         }
     }
     ExtBitmap.ExtBitmap ebDotNet = new ExtBitmap.ExtBitmap();
     using (Chrono chrono = new Chrono("Full screen capture with FastFind"))
     {
         FastFindWrapper.SetHWnd(IntPtr.Zero, false);
         chrono.Success = FastFindWrapper.SnapShot(0, 0, 0, 0, 2) != 0;
         Assert.IsTrue(chrono.Success == true);
     }
 }
Пример #2
0
        /// <summary>
        /// Initializes the Bot.
        /// </summary>
        public static void Initialize(MainViewModel vm)
        {
            // Store in properties so we can access in the SubFunctions
            Bot = vm;

            Bot.Output = string.Format(Properties.Resources.OutputWelcomeMessage, Properties.Resources.AppName);
            Bot.Output = Properties.Resources.OutputBotIsStarting;

            // Check if BlueStack is running
            FastFindWrapper.SetHWnd(BlueStackHelper.GetBlueStackWindowHandle(), true);
            if (!BlueStackHelper.IsBlueStackRunning)
            {
                Bot.Output = Properties.Resources.OutputBSNotFound;

                Bot.IsExecuting = false;
                return;
            }

            if (!BlueStackHelper.IsRunningWithRequiredDimensions)
            {
                Bot.Output = Properties.Resources.OutputBSNotRunningWithDimensions;
                Bot.Output = Properties.Resources.OutputBSApplyDimensionsIntoRegistry;

                if (!BlueStackHelper.SetDimensionsIntoRegistry())
                {
                    // Woops! Something went wrong, log the error!
                    Bot.Output = Properties.Resources.OutputBSApplyDimensionsError;

                    Bot.IsExecuting = false;
                    return;
                }
                else
                {
                    Bot.Output = Properties.Resources.OutputBSAppliedDimensionsIntoRegistry;
                }

                // Restart BlueStack
                // Wait until restart and continue...

                BlueStackHelper.ActivateBlueStack();
            }

            CreateDirectory(GlobalVariables.LogPath);
            CreateDirectory(GlobalVariables.ScreenshotZombieAttacked);
            CreateDirectory(GlobalVariables.ScreenshotZombieSkipped);

            WriteLicense();

            // Run Everything related to the bot in the background
            var thread = new Thread(() =>
            {
                while (Bot.IsExecuting)
                {
                    Thread.Sleep(1000);
                    //Bot.Output = "Loop test...";
                    //Bot.Output = "Minimum Gold is: " + Bot.MinimumGold; // Changing values on the fly works as expected
                    //Bot.Output = "Try changing values on the fly.";

                    MainScreen.CheckMainScreen();
                    Thread.Sleep(1000);

                    MainScreen.ZoomOut();
                    Thread.Sleep(1000);

                    Village.TrainTroops();
                    Thread.Sleep(1000);

                    Village.RequestTroops();
                    Thread.Sleep(1000);

                    //SubFunctions.Village.Collect();

                    //Idle();

                    //SubFunctions.Attack.AttackMain();
                }
                ;
            })
            {
                IsBackground = true
            };

            thread.Start();
        }
Пример #3
0
        /// <summary>
        /// Initializes the Bot.
        /// </summary>
        public static void Initialize(MainViewModel vm)
        {
            // Store in properties so we can access in the SubFunctions
            Bot = vm;
            Bot.ClearOutput();

            Bot.WriteToOutput(string.Format(Resources.OutputWelcomeMessage, Resources.AppName));
            Bot.WriteToOutput(Resources.OutputBotIsStarting);

            // Check if BlueStacks is running
            if (!BlueStacksHelper.IsBlueStacksRunning)
            {
                Bot.WriteToOutput(Resources.OutputBSNotFound, GlobalVariables.OutputStates.Error);

                Bot.IsExecuting = false;
                return;
            }

            if (!BlueStacksHelper.IsRunningWithRequiredDimensions)
            {
                Bot.WriteToOutput(Resources.OutputBSNotRunningWithDimensions);
                Bot.WriteToOutput(Resources.OutputBSApplyDimensionsIntoRegistry);

                if (!BlueStacksHelper.SetDimensionsIntoRegistry())
                {
                    // Woops! Something went wrong, log the error!
                    Bot.WriteToOutput(Resources.OutputBSApplyDimensionsError, GlobalVariables.OutputStates.Error);

                    Bot.IsExecuting = false;
                    return;
                }
                else
                {
                    Bot.WriteToOutput(Resources.OutputBSAppliedDimensionsIntoRegistry);
                }

                // Restart BlueStacks
                // Wait until restart and continue...

                BlueStacksHelper.ActivateBlueStacks();
            }

            CreateDirectory(GlobalVariables.LogPath);
            CreateDirectory(GlobalVariables.ScreenshotZombieAttacked);
            CreateDirectory(GlobalVariables.ScreenshotZombieSkipped);

            WriteLicense();

            // Run Everything related to the bot in the background
            var thread = new Thread(() =>
            {
                while (Bot.IsExecuting)
                {
                    FastFindWrapper.SetHWnd(BlueStacksHelper.GetBlueStacksWindowHandle(), true);

                    MainScreen.CheckMainScreen();
                    Thread.Sleep(1000);

                    MainScreen.ZoomOut();
                    Thread.Sleep(1000);

                    CoCHelper.Click(ScreenData.OpenChatBtn);
                    Thread.Sleep(1000);
                    string str = ReadText.GetString(151);
                    System.Windows.MessageBox.Show(str);

                    Village.ReArmTraps();
                    Thread.Sleep(1000);

                    Barrack.TrainTroops();
                    Thread.Sleep(1000);

                    Barrack.Boost();
                    Thread.Sleep(1000);

                    RequestAndDonate.RequestTroops();
                    Thread.Sleep(1000);

                    RequestAndDonate.DonateCC();
                    Thread.Sleep(1000);

                    Village.CollectResources();
                    Thread.Sleep(1000);

                    Village.UpgradeWalls();
                    Thread.Sleep(1000);

                    Village.Idle();
                    Thread.Sleep(1000);

                    //Attack.AttackMain();
                }
                ;
            })
            {
                IsBackground = true
            };

            thread.Start();
        }