Пример #1
0
        /// <summary>
        /// Search for a given color within a color list, scanning all the client area of BS. Faster then PixelSearch, as it doesn't do a new capture each time.
        /// </summary>
        /// <param name="left"></param>
        /// <param name="top"></param>
        /// <param name="right"></param>
        /// <param name="bottom"></param>
        /// <param name="color1"></param>
        /// <param name="variation"></param>
        /// <param name="forceCapture"></param>
        /// <returns></returns>
        public static Point FullScreenPixelSearch(ColorList colors, int variation, bool forceCapture = false)
        {
            if (!TakeFullScreenCapture(forceCapture))
            {
                return(Point.Empty);
            }
            FastFindWrapper.ResetColors();
            foreach (Color color in colors)
            {
                FastFindWrapper.AddColor(color.ToArgb());
            }
            int xRef = 0, yRef = 0;

            if (FastFindWrapper.ColorsPixelSearch(ref xRef, ref yRef, DEFAULT_SNAP) == 0)
            {
                return(Point.Empty);
            }
            return(new Point(xRef, yRef));
        }
Пример #2
0
        /// <summary>
        /// Beware: do not use this function extensively, at it does a screen shot each time.
        /// </summary>
        /// <param name="left"></param>
        /// <param name="top"></param>
        /// <param name="right"></param>
        /// <param name="bottom"></param>
        /// <param name="color1"></param>
        /// <param name="variation"></param>
        /// <param name="forceCapture"></param>
        /// <returns></returns>
        static public Point PixelSearch(int left, int top, int right, int bottom, ColorList colors, int variation)
        {
            if (!TakeCustomCapture(left, top, right, bottom))
            {
                return(Point.Empty);
            }
            FastFindWrapper.ResetColors();
            foreach (Color color in colors)
            {
                FastFindWrapper.AddColor(color.ToArgb());
            }
            int xRef = (left + right) / 2, yRef = (top + bottom) / 2;

            if (FastFindWrapper.ColorsPixelSearch(ref xRef, ref yRef, CUSTOM_SNAP) == 0)
            {
                return(Point.Empty);
            }
            return(new Point(xRef, yRef));
        }