diff --git a/robotgo.go b/robotgo.go index f2c56ff..dcefaba 100644 --- a/robotgo.go +++ b/robotgo.go @@ -62,7 +62,7 @@ import ( ) const ( - version string = "v0.47.0.445, Mount Cook!" + version string = "v0.47.0.447, Mount Cook!" ) type ( @@ -112,10 +112,20 @@ func Try(fun func(), handler func(interface{})) { |_______/ \______|| _| `._____||_______||_______||__| \__| */ -// GetPixelColor get pixel color +// GetPxColor get pixel color return C.MMRGBHex +func GetPxColor(x, y int) C.MMRGBHex { + cx := C.size_t(x) + cy := C.size_t(y) + + color := C.get_Pixel_Color(cx, cy) + return color +} + +// GetPixelColor get pixel color return string func GetPixelColor(x, y int) string { cx := C.size_t(x) cy := C.size_t(y) + color := C.aGetPixelColor(cx, cy) // color := C.aGetPixelColor(x, y) gcolor := C.GoString(color) diff --git a/screen/goScreen.h b/screen/goScreen.h index f0ae81e..98a4f03 100644 --- a/screen/goScreen.h +++ b/screen/goScreen.h @@ -19,6 +19,21 @@ void padHex(MMRGBHex color, char* hex){ snprintf(hex, 7, "%06x", color); } +MMRGBHex get_Pixel_Color(size_t x, size_t y){ + MMBitmapRef bitmap; + MMRGBHex color; + + if (!pointVisibleOnMainDisplay(MMPointMake(x, y))){ + return color; + } + + bitmap = copyMMBitmapFromDisplayInRect(MMRectMake(x, y, 1, 1)); + // bitmap = MMRectMake(x, y, 1, 1); + + color = MMRGBHexAtPoint(bitmap, 0, 0); + + return color; +} char* aGetPixelColor(size_t x, size_t y){ MMBitmapRef bitmap;