Find text using text color (not background color)

Is there any property to use with Click or Find kind of commands to find out if a particular text is of some color?
I need to find if a link or button is disabled or not, and take actions further. Both the active and disabled links will have same background color but different foreground color. Not sure if the contrast and contrast-color would help here. Appreciate any help.

Hi, I would use contrast colour for this. Pick out the disabled text colour and the enabled text colour and add a search rectangle around the button.

You can add if statements around these too depending on the logic you desire.

// Expecting button to be disabled

set buttonText to ReadText([840,176,1130,214], contrast:"On", contrastColor:"#FFFFFF", contrastTolerance:"45")

Log buttonText

// Expecting button to be enabled
set buttonText to ReadText([840,176,1130,214], contrast:"On", contrastColor:"#FC2B28", contrastTolerance:"45")

Log buttonText

Hello - I have already tried with this but no luck. It is finding the text irrespective of color that I am passing or no idea only if it is considering background color for contrast.

Also, tried to check the color using ColorAtLocation, and it gives same color for both enabled text and disabled text locations.

Attached the image for ref.

You can capture two images for a link or button disabled and enabled.

params searchArea
set the searchRectangle to searchArea # for debug
repeat with y = searchArea.Top to searchArea.Bottom
repeat with x = searchArea.Left to searchArea.Right
set dotColor to ColorAtLocation(x, y)
log “color at [”&x&“, “&y&”]=(”&dotColor&“)” # for debug
set RGB to split(dotColor, “,”)
set redPart to item 1 of RGB
set greenPart to item 2 of RGB
set bluePart to item 3 of RGB

	if (redPart<128 and greenPart>201 and bluePart<128) or \
			(greenPart>210 and redPart + bluePart<180) 
		return "green"
	else if redPart>201 and greenPart<128 and bluePart<128
		return "red"
	else if (redPart = 0) and \
			(greenPart between 113 and 126) and \
			(bluePart between 147 and 159)
		return "blue"
	else if (redPart between 125 and 130) and \
			(greenPart between 74 and 76) and \
			(bluePart between 46 and 50)
		return "yellow"
	end if
end repeat

end repeat
set the searchRectangle to empty # for debug