public static bool FindAndClickButton(CATSimage button, int tries = 1, double tolerance = 0.2) { if (ImageRecognition.FindButton(button, tries) == 0) { return(false); } ADB.ClickButton(button, tolerance); return(true); }
public static bool ClickButtonWithFind(CATSimage button, int tries = 1, double tolerance = 0.2) { Rectangle r = ImageRecognition.FindButtonRectangle(button, tries); if (r.IsEmpty) { return(false); } else { ADB.ClickButtonRectangle(r, tolerance); } return(true); }
public static bool FindAndClickButtonWithSleep(CATSimage button, int seconds = 2, double tolerance = 0.2) { for (int i = 0; i < seconds; i++) { if (ImageRecognition.FindButton(button, 2) > 0) { ADB.ClickButton(button, tolerance); return(true); } Thread.Sleep(1000); } return(false); }
public static Bitmap TakeScreenshot(CATSimage button = null, bool keepSize = true) { try { string error = ""; error += RunCommand("adb.exe", "shell screencap -p /sdcard/screenshot.png"); RunCommand("adb.exe", "pull /sdcard/screenshot.png"); error += RunCommand("adb.exe", "shell rm /sdcard/screenshot.png"); if (error != "") { Game.RestartApp(); } Bitmap screenBitmap; if (File.Exists("screenshot.png")) { Image screenImage = Image.FromFile("screenshot.png"); screenBitmap = new Bitmap(screenImage.Width, screenImage.Height, System.Drawing.Imaging.PixelFormat.Format24bppRgb); using (Graphics g = Graphics.FromImage(screenBitmap)) { g.DrawImage(screenImage, new Rectangle(0, 0, screenImage.Width, screenImage.Height)); } screenImage.Dispose(); } else { throw new Exception("screenshot.png doesn't exist"); } if (button != null) { ImageRecognition.CropImage(button, ref screenBitmap); } if (!keepSize) { ImageRecognition.ResizeImage(ref screenBitmap); } return(screenBitmap); } catch (Exception e) { Logger.Log("TakeScreenshot Exception: " + e.Message + e.StackTrace, debug: true); return(null); } }
public static bool RepeatFindButton(CATSimage button, int seconds = 2, int sleep = 0) { if (ImageRecognition.FindButton(button, SettingsManager.settings.GetLatency()) > 0) { return(true); } for (int i = 0; i < seconds; i++) { if (ImageRecognition.FindButton(button, 2) > 0) { return(true); } ADB.ClickBack(); if (sleep > 0) { Thread.Sleep(sleep); } } return(false); }
public static int FindAllButtons(CATSimage button, int tries = 1) { return(ImageRecognition.FindButton(button, tries)); }
public static bool FindButton(CATSimage button, int tries = 1) { return(ImageRecognition.FindButton(button, tries) > 0); }
public static List <int> ReadImageValue(CATSimage button) { return(ImageRecognition.GetButtonNumbers(button)); }