If-Then Statements (and color detection at coordinates) for use with the Touch Bar

I'd be interested in having if-then statements for the Touch Bar. For example:

If [at coordinates 100, 200 from Top Left of Active Window] there is [color rgb(255,0,0)] then change Touch Bar button from [rgb(255,255,0)] to [rgb(255,0,0)].

A practical use for this would be on discord, to detect if you are in a call or not. If you are, the Touch Bar would switch to a voice-chat oriented UI rather than a text input based UI, and could have options to mute, deafen, or hang up.

This is just an idea, but it would be cool to see this in a future update. Let me know what you think!