我正在寻找一种方法来获得光标下的像素 colored颜色 值.
这当然可以在任何windows 上使用,而不仅仅是像Winit这样的"铁 rust 拥有的"windows .
我找到了几个library of window capture和solution in other language ,但都不能满足我的需要.
我正在寻找一种方法来获得光标下的像素 colored颜色 值.
这当然可以在任何windows 上使用,而不仅仅是像Winit这样的"铁 rust 拥有的"windows .
我找到了几个library of window capture和solution in other language ,但都不能满足我的需要.
下面是一个使用autopilot的简单跨平台解决方案.
首先使用mouse::location()
获取光标位置,然后使用screen::get_color(position)
获取屏幕上的像素.
完整的样本:
fn main() {
let mouse_location = autopilot::mouse::location();
let pixel = autopilot::screen::get_color(mouse_location).unwrap();
println!(
"Pixel color under cursor (RGBA): {},{},{},{}",
pixel.0[0], pixel.0[1], pixel.0[2], pixel.0[3]
)
}