Wow, that is a tall order that you have there...

I think that autoit has the ability to sample screen x/y cords and return the color of the pixels.. or I think it does.

And there are other scriptable programs out there made to do just this type of automation, but most of these are used for automated gamming bot's (google for actool).

if autoit can do a screen sample, COM object control would let you use the scripting engine of your choice.