예제 #1
0
        public static Color GetPixelColor(Process process, int x, int y)
        {
            IntPtr mainWindowHandle = process.MainWindowHandle;
            Color  result;

            if (mainWindowHandle == IntPtr.Zero || process.HasExited)
            {
                result = Color.Empty;
            }
            else
            {
                IntPtr dC    = ProgramThread.GetDC(mainWindowHandle);
                uint   pixel = ProgramThread.GetPixel(dC, x, y);
                ProgramThread.ReleaseDC(mainWindowHandle, dC);
                result = Color.FromArgb((int)(pixel & 255u), (int)(pixel & 65280u) >> 8, (int)(pixel & 16711680u) >> 16);
            }
            return(result);
        }
예제 #2
0
        public static bool PixelColorIsWite(Process process, int x, int y)
        {
            IntPtr mainWindowHandle = process.MainWindowHandle;
            bool   result;

            if (mainWindowHandle == IntPtr.Zero || process.HasExited)
            {
                result = false;
            }
            else
            {
                IntPtr dC    = ProgramThread.GetDC(mainWindowHandle);
                uint   pixel = ProgramThread.GetPixel(dC, x, y);
                ProgramThread.ReleaseDC(mainWindowHandle, dC);
                Color color = Color.FromArgb((int)(pixel & 255u), (int)(pixel & 65280u) >> 8, (int)(pixel & 16711680u) >> 16);
                result = (color.R > 240 && color.G > 240 && color.B > 240);
            }
            return(result);
        }