mirror of
https://github.com/go-vgo/robotgo.git
synced 2025-06-02 23:23:55 +00:00
add more find bitmap
This commit is contained in:
parent
b8e7e584a7
commit
02ca8ea6fe
@ -77,6 +77,27 @@ MMPoint bitmap_find_bitmap(MMBitmapRef bitmap, MMBitmapRef sbitmap, float tolera
|
|||||||
return point;
|
return point;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MMPoint *find_every_bitmap(MMBitmapRef bitmap, MMBitmapRef sbitmap, float tolerance, MMPoint *list){
|
||||||
|
if (!bitmap_ready(bitmap) || !bitmap_ready(sbitmap)) return NULL;
|
||||||
|
|
||||||
|
MMPoint point;
|
||||||
|
MMPointArrayRef pointArray;
|
||||||
|
MMRect rect = MMBitmapGetBounds(bitmap);
|
||||||
|
|
||||||
|
if (findBitmapInRect(bitmap, sbitmap, &point,
|
||||||
|
rect, tolerance) == 0) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
pointArray = findAllBitmapInRect(bitmap, sbitmap, rect, tolerance);
|
||||||
|
if (pointArray == NULL) return NULL;
|
||||||
|
|
||||||
|
memcpy(list, pointArray->array, sizeof(MMPoint) * pointArray->count);
|
||||||
|
destroyMMPointArray(pointArray);
|
||||||
|
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
MMPoint aFindBitmap(MMBitmapRef bit_map, MMRect rect){
|
MMPoint aFindBitmap(MMBitmapRef bit_map, MMRect rect){
|
||||||
// MMRect rect;
|
// MMRect rect;
|
||||||
// rect.size.width = 10;
|
// rect.size.width = 10;
|
||||||
|
42
robotgo.go
42
robotgo.go
@ -55,7 +55,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
version string = "v0.46.0.401, Pyrenees Mountains!"
|
version string = "v0.46.0.402, Pyrenees Mountains!"
|
||||||
)
|
)
|
||||||
|
|
||||||
// GetVersion get version
|
// GetVersion get version
|
||||||
@ -597,6 +597,46 @@ func FindBitmap(args ...interface{}) (int, int) {
|
|||||||
return int(pos.x), int(pos.y)
|
return int(pos.x), int(pos.y)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// FindEveryBitmap find the every bitmap
|
||||||
|
func FindEveryBitmap(args ...interface{}) (int, int) {
|
||||||
|
var (
|
||||||
|
bit C.MMBitmapRef
|
||||||
|
sbit C.MMBitmapRef
|
||||||
|
tolerance C.float
|
||||||
|
lpos C.MMPoint
|
||||||
|
)
|
||||||
|
|
||||||
|
bit = args[0].(C.MMBitmapRef)
|
||||||
|
if len(args) > 1 {
|
||||||
|
sbit = args[1].(C.MMBitmapRef)
|
||||||
|
} else {
|
||||||
|
sbit = CaptureScreen()
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(args) > 2 {
|
||||||
|
tolerance = C.float(args[2].(float32))
|
||||||
|
} else {
|
||||||
|
tolerance = 0.5
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(args) > 3 {
|
||||||
|
lpos.x = C.size_t(args[3].(int))
|
||||||
|
lpos.y = 0
|
||||||
|
} else {
|
||||||
|
lpos.x = 0
|
||||||
|
lpos.y = 0
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(args) > 4 {
|
||||||
|
lpos.x = C.size_t(args[3].(int))
|
||||||
|
lpos.y = C.size_t(args[4].(int))
|
||||||
|
}
|
||||||
|
|
||||||
|
pos := C.find_every_bitmap(bit, sbit, tolerance, &lpos)
|
||||||
|
// fmt.Println("pos----", pos)
|
||||||
|
return int(pos.x), int(pos.y)
|
||||||
|
}
|
||||||
|
|
||||||
// FindBit find the bitmap
|
// FindBit find the bitmap
|
||||||
func FindBit(args ...interface{}) (int, int) {
|
func FindBit(args ...interface{}) (int, int) {
|
||||||
var bit C.MMBitmapRef
|
var bit C.MMBitmapRef
|
||||||
|
Loading…
Reference in New Issue
Block a user