如何从 Oracle VM 获取像素颜色

How to get pixel color from oracle VM

我有一个用 Java 编写的脚本,它使用 Java 机器人 class 的 getPixelColor 方法获取像素颜色,并将其与另一种颜色进行比较,看它们是否相同.它在我的电脑上运行良好,但是当我在安装了 windows 10 的 Oracle VM VirtualBox 中使用它时,像素总是显示白色。 (HSB 0,0,1)。 有没有办法从虚拟机中获取像素颜色?我是缺少设置还是应该更改密码?

代码和结果图片如下:this is the code that checks if the colors match, with a certain tolerance, it returns a booleanThese are the printed results: if all ToCompare values lie between targetplus and targetmin it will return a true

这是我的第一个问题,请保持温和 :)。

经过更多搜索,我发现机器人 class 能够从虚拟机内部获取颜色,我在代码的其他部分犯了一个错误,并且由于 multi线程(而虚拟机在 1 个线程上运行)已通过更改虚拟机设置解决。