How can i search a specific area on the screen. Right now i can only do a single pixel or point, but i want to do an area. Can i make a moveable label that takes up whatever image is behind it and then search that label? If yes, how can i make that label separate from the form?

You need to explain more of what you are trying to do. How are you 'searching' a pixel? What are you trying to accomplish with your "label separate from the form'?

Right now i only have it searching the mouse pointer. I want to have a draggable box that is also resizeable, that shows the border but is clear on the inside, and shows whatever is on the other side, and search inside that box for a specific color and return true if its there. How would i accomplish this?

Create a form with no title bar and set the background to transparent (I believe that someone posted how to do that on this site, you'll have to search). Allow the user to resize the form. Capture the form image (not sure if this will get the background, but it's worth a try. Otherwise you'll have to use GDI to get the screen info).

I made the form(its a square that is transparent), but its not draggable or resizable. Getting rid of the title bar and everything got rid of the ability to drag. I dont know how to capture the image in the form, but i found ActiveForm.BackgroundImage; Can i use that? Also i have no idea how to search the image for a color(i am a noob). I know it has something to do with for statements though.

Edited 6 Years Ago by Steve_Jones: n/a

Color c = GetColorAt(MousePosition);
            label1.BackColor = c;
            Bitmap backGround = (Bitmap)Form2.ActiveForm.BackgroundImage;
            SearchColor(c, backGround);

private void SearchColor(Color c,Bitmap image)
        {
            for (int x = 0; x < image.Width; ++x)
            {
                for (int y = 0; y < image.Height; ++y)
                {
                    image.GetPixel(x, y);
                    if (c.R <= 100 & c.G <= 100 & c.B >= 150 || c.R <= 100 & c.G >= 150 & c.B <= 100)
                    {
                        MessageBox.Show("got it");
                    }
                }
            }
        } 

This is a complete guessing try, but it keeps telling me image is null, and throws me an exception.
System.NullReferenceException: Object reference not set to an instance of an object.

Edited 3 Years Ago by Dani: Formatting fixed

Ive never had to bump here, but it seems i got overlooked and dropped down the list real far. But overall the response time and help has been phenomenal. I hope someone continues this help though, im still searching for answers myself, but nothing seems to fit my current situation so far that ive found or given me what i needed.

Bitmap bmpScreenshot;
bmpScreenshot = GetScreen();
Rectangle rectangle = new Rectangle(630, 470, 20, 20);
SearchColor(bmpScreenshot);

private Bitmap GetScreen()
         {
             var bitmap = new Bitmap(rectangle.Width, rectangle.Height, PixelFormat.Format32bppArgb);
             Graphics graphics = Graphics.FromImage(bitmap);
             graphics.CopyFromScreen(rectangle.Left, rectangle.Top, 0, 0, rectangle.Size);
             return bitmap;
         }

public static void SearchColor(Bitmap image)
         {
             for (int x = 0; x < image.Width; ++x)
             {
                 for (int y = 0; y < image.Height; ++y)
                 {
                     Color b = image.GetPixel(x, y);
                     if (b.R <= 100 & b.G >= 150 & b.B <= 100)
                     {
                         MessageBox.Show("Got It");

                     }
                 }
             }
         }

I found out how, here is the solution.

Edited 3 Years Ago by Dani: Formatting fixed

This question has already been answered. Start a new discussion instead.