I am looking for a way of creating a program that will perform a mouse click where it finds a certain color on the screen.
For example if there is a red box on the screen, I would want the program to click on the red box in the center of it.
How could I accomplish this in C#?
As you only wanted a general way, I didn’t really make it perfect, but here is the idea:
Have a method for taking a screen shot:
And a method to find a certain color in a bitmap:
Note that this implementation can be DRASTICALLY improved using unsafe code and LockBits (read here and here).
Another method you’ll need is one for clicking a certain point:
And finally, one to wrap it all up:
Then, the usage would be: