winapi = {version = "0.3.9",features = ["winuser"]}
use std::ptr::null_mut;
use winapi::um::wingdi::{ GetBValue, GetGValue, GetPixel, GetRValue};
use winapi::um::winuser::{GetCursorPos, GetDC, ReleaseDC};
use winapi::shared::windef::POINT;
// 获取鼠标位置
// GetCursorPos is a function from winapi
pub fn get_cursor_pos() -> POINT {
    let mut point = POINT { x: 0, y: 0 };
    unsafe {
        GetCursorPos(&mut point);
    }
    point
}
// 获取像素颜色
#[derive(Debug)]
pub struct Color {
    r: u8,
    g: u8,
    b: u8,
    a: u8,
}
pub fn get_pixel_color(point: POINT) -> Color {
    // let point = get_cursor_pos();
    unsafe {
        let hdc = GetDC(null_mut());
        let color_value = GetPixel(hdc, point.x, point.y);
        ReleaseDC(null_mut(), hdc);
        let color = Color {
            r: GetRValue(color_value),
            g: GetGValue(color_value),
            b: GetBValue(color_value),
            a: 0,
        };
        color
    }
}