public OsrsScanData SearchScreenForColors(List <Color> colors, OsrsImage image, ScanBoundaries boundaries = null) { LoggingUtility.WriteToAuditLog("Starting Color Search"); OsrsScanData response = null; var osrsWindow = HwndInterface.GetHwndFromTitle("Old School RuneScape"); var windowSize = HwndInterface.GetHwndSize(osrsWindow); var windowLocation = HwndInterface.GetHwndPos(osrsWindow); HwndInterface.ActivateWindow(osrsWindow); var screenshot = TakeScreenshot(); #region Scan Boundaries Calculation if (boundaries == null) { boundaries = new ScanBoundaries(); boundaries.MinX = windowLocation.X < 0 ? 0 : windowLocation.X; boundaries.MinY = windowLocation.Y < 0 ? 0 : windowLocation.Y; boundaries.MaxX = (windowLocation.X + windowSize.Width) > screenshot.Width ? screenshot.Width : (windowLocation.X + windowSize.Width); boundaries.MaxY = (windowLocation.Y + windowSize.Height) > screenshot.Height ? screenshot.Height : (windowLocation.Y + windowSize.Height); } #endregion response = FindColorsInImage(colors, screenshot, boundaries); //response = FindColorsInImage(colors, image.ImageBitmap, new ScanBoundaries { MinX = 0, MinY = 0, MaxX = image.ImageBitmap.Width, MaxY = image.ImageBitmap.Height }); LoggingUtility.WriteToAuditLog("Color Search Complete"); return(response); }
public List <OsrsScanData> SearchScreenForImages(List <OsrsImage> osrsImages, ScanBoundaries boundaries = null, bool getSingleOccurrence = false) { var response = new List <OsrsScanData>(); var osrsWindow = HwndInterface.GetHwndFromTitle("Old School RuneScape"); var windowSize = HwndInterface.GetHwndSize(osrsWindow); var windowLocation = HwndInterface.GetHwndPos(osrsWindow); HwndInterface.ActivateWindow(osrsWindow); var screenshot = TakeScreenshot(); #region Scan Boundaries Calculation if (boundaries == null) { boundaries = new ScanBoundaries(); var imgMaxX = osrsImages.Max(x => x.ImageBitmap.Width); var imgMaxY = osrsImages.Max(x => x.ImageBitmap.Height); boundaries.MinX = windowLocation.X < 0 ? 0 : windowLocation.X; boundaries.MinY = windowLocation.Y < 0 ? 0 : windowLocation.Y; boundaries.MaxX = (windowLocation.X + windowSize.Width) > screenshot.Width ? screenshot.Width - imgMaxX : (windowLocation.X + windowSize.Width) - imgMaxX; boundaries.MaxY = (windowLocation.Y + windowSize.Height) > screenshot.Height ? screenshot.Height - imgMaxY : (windowLocation.Y + windowSize.Height) - imgMaxY; } #endregion response = FindAllBitmapsInImage(osrsImages, screenshot, boundaries, getSingleOccurrence); return(response); }
public static void ClickLocation(Point location, bool leftClick = true) { var osrsWindow = HwndInterface.GetHwndFromTitle("Old School RuneScape"); HwndInterface.ActivateWindow(osrsWindow); Cursor.Position = location; if (leftClick) { MouseEvent.MouseLeftClick(); } else { MouseEvent.MouseRightClick(); } }
/// <summary> /// Gets the first top-level HwndObject with the given title. /// </summary> /// <param name="title"></param> /// <returns></returns> public static HwndObject GetWindowByTitle(string title) { return(new HwndObject(HwndInterface.GetHwndFromTitle(title))); }