static public void Test() { FastFindWrapper.SetHWnd(BlueStackHelper.GetBlueStackWindowHandle(), true); // Bind FastFind with BlueStack window FastFindWrapper.SnapShot(0, 0, 860, 720, 0); // Take full window capture FastFindWrapper.SnapShot(200, 200, 600, 500, 1); // Take just a small part FastFindWrapper.SetDebugMode(FastFindWrapper.DEBUG_STREAM_SYSTEM_DETAIL); // Console and File - Detailed System Message IntPtr version = FastFindWrapper.FFVersion(); string s = Marshal.PtrToStringAnsi(version); MessageBox.Show("FastFind Version " + s); if (!FastFindWrapper.SaveJPG(0, fullSize, 100)) { MessageBox.Show("Failed to save full BS capture into " + fullSize + FastFindWrapper.GetLastFileSuffix().ToString() + ".JPG"); } else { MessageBox.Show("Succeeded to save full BS capture into " + fullSize + FastFindWrapper.GetLastFileSuffix().ToString() + ".JPG"); } if (!FastFindWrapper.SaveJPG(1, smallSize, 100)) { MessageBox.Show("Failed to save partial BS capture into " + smallSize + FastFindWrapper.GetLastFileSuffix().ToString() + ".JPG"); } else { MessageBox.Show("Succeeded to save partial BS capture into " + smallSize + FastFindWrapper.GetLastFileSuffix().ToString() + ".JPG"); } FastFindHelper.GetPixel(10, 10); }
/// <summary> /// Takes a screen shot of the full client area of the BlueStack window /// </summary> /// <returns></returns> static private bool TakeCustomCapture(int left, int top, int right, int bottom) { FastFindWrapper.SetHWnd(BlueStackHelper.GetBlueStackWindowHandle(), true); // Bind FastFind with BlueStack window, considers only ClientArea if (FastFindWrapper.SnapShot(left, top, right, bottom, CUSTOM_SNAP) == 0) { Debug.Assert(false, "FF Capture failed"); return(false); } return(true); }
/// <summary> /// Takes a screen shot of the full client area of the BlueStack window /// </summary> /// <returns></returns> static public bool TakeFullScreenCapture(bool forceNew = false) { if ((lastFullCapture != null && lastFullCapture.ElapsedMilliseconds > MINIMUM_DELAY_BETWEEN_CAPTURES) || forceNew) { FastFindWrapper.SetHWnd(BlueStackHelper.GetBlueStackWindowHandle(), true); // Bind FastFind with BlueStack window, considers only ClientArea if (FastFindWrapper.SnapShot(0, 0, 0, 0, DEFAULT_SNAP) == 0) { lastFullCapture = null; Debug.Assert(false, "FF Capture failed"); return(false); } lastFullCapture = Stopwatch.StartNew(); } return(true); }
/// <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(); }