mirror of
https://github.com/go-vgo/robotgo.git
synced 2025-05-31 06:13:55 +00:00
update bitmap name and add count of bitmap
This commit is contained in:
parent
aa247025d2
commit
9f0400167b
@ -58,18 +58,18 @@ MMBitmapRef bitmap_deepcopy(MMBitmapRef bitmap){
|
||||
return bitmap == NULL ? NULL : copyMMBitmap(bitmap);
|
||||
}
|
||||
|
||||
MMPoint find_bitmap(MMBitmapRef bitmap, MMBitmapRef sbitmap, float tolerance){
|
||||
MMPoint find_bitmap(MMBitmapRef bitmap, MMBitmapRef sbit, float tolerance){
|
||||
MMPoint point = {-1, -1};
|
||||
// printf("tolenrance=%f\n", tolerance);
|
||||
if (!bitmap_ready(sbitmap) || !bitmap_ready(bitmap)) {
|
||||
if (!bitmap_ready(sbit) || !bitmap_ready(bitmap)) {
|
||||
printf("bitmap is not ready yet!\n");
|
||||
return point;
|
||||
}
|
||||
|
||||
MMRect rect = MMBitmapGetBounds(sbitmap);
|
||||
MMRect rect = MMBitmapGetBounds(sbit);
|
||||
// printf("x=%d,y=%d,width=%d,height=%d\n", rect.origin.x, rect.origin.y, rect.size.width, rect.size.height);
|
||||
|
||||
if (findBitmapInRect(bitmap, sbitmap, &point,
|
||||
if (findBitmapInRect(bitmap, sbit, &point,
|
||||
rect, tolerance) == 0) {
|
||||
return point;
|
||||
}
|
||||
@ -77,19 +77,19 @@ MMPoint find_bitmap(MMBitmapRef bitmap, MMBitmapRef sbitmap, float tolerance){
|
||||
return point;
|
||||
}
|
||||
|
||||
MMPoint *find_every_bitmap(MMBitmapRef bitmap, MMBitmapRef sbitmap, float tolerance, MMPoint *list){
|
||||
if (!bitmap_ready(bitmap) || !bitmap_ready(sbitmap)) return NULL;
|
||||
MMPoint *find_every_bitmap(MMBitmapRef bitmap, MMBitmapRef sbit, float tolerance, MMPoint *list){
|
||||
if (!bitmap_ready(bitmap) || !bitmap_ready(sbit)) return NULL;
|
||||
|
||||
MMPoint point;
|
||||
MMPointArrayRef pointArray;
|
||||
MMRect rect = MMBitmapGetBounds(bitmap);
|
||||
|
||||
if (findBitmapInRect(bitmap, sbitmap, &point,
|
||||
if (findBitmapInRect(bitmap, sbit, &point,
|
||||
rect, tolerance) == 0) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
pointArray = findAllBitmapInRect(bitmap, sbitmap, rect, tolerance);
|
||||
pointArray = findAllBitmapInRect(bitmap, sbit, rect, tolerance);
|
||||
if (pointArray == NULL) return NULL;
|
||||
|
||||
memcpy(list, pointArray->array, sizeof(MMPoint) * pointArray->count);
|
||||
@ -98,6 +98,14 @@ MMPoint *find_every_bitmap(MMBitmapRef bitmap, MMBitmapRef sbitmap, float tolera
|
||||
return list;
|
||||
}
|
||||
|
||||
int count_of_bitmap(MMBitmapRef bitmap, MMBitmapRef sbit, float tolerance){
|
||||
if (!bitmap_ready(bitmap) || !bitmap_ready(sbit)) return 0;
|
||||
|
||||
MMRect rect = MMBitmapGetBounds(bitmap);
|
||||
|
||||
return countOfBitmapInRect(bitmap, sbit, rect, tolerance);
|
||||
}
|
||||
|
||||
MMPoint aFindBitmap(MMBitmapRef bit_map, MMRect rect){
|
||||
// MMRect rect;
|
||||
// rect.size.width = 10;
|
||||
|
35
robotgo.go
35
robotgo.go
@ -62,7 +62,7 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
version string = "v0.47.0.476, Mount Cook!"
|
||||
version string = "v0.47.0.477, Mount Cook!"
|
||||
)
|
||||
|
||||
type (
|
||||
@ -654,6 +654,16 @@ func KeyToggle(args ...string) string {
|
||||
return C.GoString(str)
|
||||
}
|
||||
|
||||
// ReadAll read string from clipboard
|
||||
func ReadAll() (string, error) {
|
||||
return clipboard.ReadAll()
|
||||
}
|
||||
|
||||
// WriteAll write string to clipboard
|
||||
func WriteAll(text string) {
|
||||
clipboard.WriteAll(text)
|
||||
}
|
||||
|
||||
// TypeString type string
|
||||
func TypeString(x string) {
|
||||
cx := C.CString(x)
|
||||
@ -671,16 +681,6 @@ func TypeStr(str string) {
|
||||
}
|
||||
}
|
||||
|
||||
// ReadAll read string from clipboard
|
||||
func ReadAll() (string, error) {
|
||||
return clipboard.ReadAll()
|
||||
}
|
||||
|
||||
// WriteAll write string to clipboard
|
||||
func WriteAll(text string) {
|
||||
clipboard.WriteAll(text)
|
||||
}
|
||||
|
||||
// TypeStrDelay type string delayed
|
||||
func TypeStrDelay(x string, y int) {
|
||||
cx := C.CString(x)
|
||||
@ -782,6 +782,19 @@ func FindEveryBitmap(args ...interface{}) (int, int) {
|
||||
return int(pos.x), int(pos.y)
|
||||
}
|
||||
|
||||
// CountBitmap count of the bitmap
|
||||
func CountBitmap(bitmap C.MMBitmapRef, sbit C.MMBitmapRef, args ...float32) int {
|
||||
var tolerance C.float
|
||||
if len(args) > 0 {
|
||||
tolerance = C.float(args[0])
|
||||
} else {
|
||||
tolerance = 0.5
|
||||
}
|
||||
|
||||
count := C.count_of_bitmap(bitmap, sbit, tolerance)
|
||||
return int(count)
|
||||
}
|
||||
|
||||
// FindBit find the bitmap, Wno-deprecated
|
||||
func FindBit(args ...interface{}) (int, int) {
|
||||
var bit C.MMBitmapRef
|
||||
|
Loading…
Reference in New Issue
Block a user