예제 #1
0
        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);
        }
예제 #2
0
 /// <summary>
 /// Returns a pixel from the client area of BlueStack.
 /// Capture will be done or refreshed automatically has needed
 /// </summary>
 /// <param name="x"></param>
 /// <param name="y"></param>
 /// <param name="forceCapture">If set to true, then a new Capture of the full client area will be done first</param>
 /// <returns>An int 0x00RRGGBB, or -1 as an error</returns>
 static public int GetPixel(int x, int y, bool forceCapture = false)
 {
     if (!TakeFullScreenCapture(forceCapture))
     {
         return(-1);
     }
     return(FastFindWrapper.GetPixel(x, y, DEFAULT_SNAP));
 }
예제 #3
0
 /// <summary>
 /// Returns a pixel from the client area of BlueStack.
 /// Capture will be done or refreshed automatically has needed
 /// </summary>
 /// <param name="point"></param>
 /// <param name="forceCapture">If set to true, then a new Capture of the full client area will be done first</param>
 /// <returns>An int 0x00RRGGBB, or -1 as an error</returns>
 static public int GetPixel(Point point, bool forceCapture = false)
 {
     if (!TakeFullScreenCapture(forceCapture))
     {
         return(-1);
     }
     return(FastFindWrapper.GetPixel(point.X, point.Y, DEFAULT_SNAP));
 }
예제 #4
0
        /// <summary>
        /// Returns a pixel from the client area of BlueStack.
        /// Capture will be done or refreshed automatically has needed
        /// </summary>
        /// <param name="point"></param>
        /// <param name="forceCapture">If set to true, then a new Capture of the full client area will be done first</param>
        /// <returns>A C# Color structure representing the color of that pixel. Returns Color.Empty as an error</returns>
        static public Color GetPixelColor(Point point, bool forceCapture = false)
        {
            if (!TakeFullScreenCapture(forceCapture))
            {
                return(Color.Empty);
            }
            int value = FastFindWrapper.GetPixel(point.X, point.Y, DEFAULT_SNAP);

            return(System.Drawing.Color.FromArgb(value));
        }
예제 #5
0
 /// <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);
 }
예제 #6
0
        /// <summary>
        /// Search for a given color within 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>
        /// <returns></returns>
        static public Point FullScreenPixelSearch(Color color1, int variation, bool forceCapture = false)
        {
            if (!TakeFullScreenCapture(forceCapture))
            {
                return(Point.Empty);
            }
            int nbMatchMin = 1, xRef = 0, yRef = 0;

            if (FastFindWrapper.GenericColorSearch(1, ref nbMatchMin, ref xRef, ref yRef, color1.ToArgb(), variation, DEFAULT_SNAP) == 0 || nbMatchMin == 0)
            {
                return(Point.Empty);
            }
            return(new Point(xRef, yRef));
        }
예제 #7
0
        /// <summary>
        /// Beware: do not use this function extensively, at it does a screen shot each time. Better use higher level functions when needed.
        /// </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, Color color1, int variation)
        {
            if (!TakeCustomCapture(left, top, right, bottom))
            {
                return(Point.Empty);
            }
            int nbMatchMin = 1, xRef = (left + right) / 2, yRef = (top + bottom) / 2;

            if (FastFindWrapper.GenericColorSearch(1, ref nbMatchMin, ref xRef, ref yRef, color1.ToArgb(), variation, CUSTOM_SNAP) == 0 || nbMatchMin == 0)
            {
                return(Point.Empty);
            }
            return(new Point(xRef, yRef));
        }
예제 #8
0
 /// <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);
 }
예제 #9
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));
        }
예제 #10
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));
        }