Input based off of pixel color on screen?

I want to write a p.o.c. Application that uses the colors of the screens to make decisions in the code. E.g. If at screen position 150x300 the pixel return color is green then go. Else if yellow slowdown . Else if red stop. Else if blue do a crazy little dance. Else do nothing.

Those colors and actions are not what I have in mind, but you get the idea. I know programs like Photoshop have a color selector. And there are other programs that will get the rgb colors of whatever is being displayed on screen. Is there a way to do this in applescript, or any 3rd party applications that are scriptable?

+edit
OSX has a tool called digital color meter. Now, how can I use this in my applescripts?

That program does not have an applescript dictionary, so you’ll have to use gui scripting to control it. The following will get the rgb colors.

set {redColor, blueColor, greenColor} to {missing value, missing value, missing value}

tell application "DigitalColor Meter" to activate
tell application "System Events"
	tell process "DigitalColor Meter"
		click menu item "Copy Color as Text" of menu 1 of menu bar item "Color" of menu bar 1
	end tell
end tell

set rgbColors to words of (the clipboard)
if (count of rgbColors) is 3 then
	set {redColor, blueColor, greenColor} to {item 1 of rgbColors, item 2 of rgbColors, item 3 of rgbColors}
else
	display dialog "There was an error getting the RGB Colors from DigitalColor Meter"
end if

return {redColor, blueColor, greenColor}

I can make this work!..maybe… Thanks!!!

+edit

Oh yeah!

set row1 to {}
repeat 7 times
	tell application "Safari" to activate
	
	
	tell application "DigitalColor Meter" to activate
	tell application "System Events"
		tell process "DigitalColor Meter"
			click menu item "Copy Color as Text" of menu 1 of menu bar item "Color" of menu bar 1
		end tell
	end tell
	set curcol to (the clipboard as text)
	set end of row1 to curcol
	set myloc to my getMouseLocation()
	
	tell application "Extra Suites"
		set x to item 1 of myloc
		set y to item 2 of myloc
		set x to x + 40
		ES move mouse {x, y}
	end tell
end repeat
on getMouseLocation()
	tell application "Extra Suites"
		set mouseLoc to (ES mouse location)
	end tell
	return mouseLoc
end getMouseLocation
row1