Hi All,
Working in Perspective, Gateway 8.0.16.
I’m attempting to get the color of a pixel at the user’s mouse coordinates.
I found this forum post from over a decade ago, which solved the problem in Vision with a few lines of Java.
Updating the original solution for Perspective, I put the following code in my view.root’s mouse OnClick event:
import java.awt.Robot
robot = java.awt.Robot()
try:
x = event.clientX
y = event.clientY
colour = robot.getPixelColor(x, y)
system.perspective.print('Color: ' + str(colour))
except Exception as e:
system.perspective.print(str(e))
The code doesn’t error out, but it always prints
Color: java.awt.Color[r=0,g=0,b=0]
,
even though the root is completely colored (not black). Anybody know if this solution should port over to Perspective, or another way to get color of a specific pixel?
Thanks in advance.