mirror of
https://github.com/go-vgo/robotgo.git
synced 2025-06-06 08:43:56 +00:00
commit
8cbae51c3e
13
robotgo.go
13
robotgo.go
@ -820,6 +820,19 @@ func TostringBitmap(bit C.MMBitmapRef) *C.char {
|
|||||||
return strBit
|
return strBit
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ToBitmap trans C.MMBitmapRef to Bitmap
|
||||||
|
func ToBitmap(bit C.MMBitmapRef) Bitmap {
|
||||||
|
bitmap := Bitmap{
|
||||||
|
ImageBuffer: (*uint8)(bit.imageBuffer),
|
||||||
|
Width: int(bit.width),
|
||||||
|
Height: int(bit.height),
|
||||||
|
Bytewidth: int(bit.bytewidth),
|
||||||
|
BitsPerPixel: uint8(bit.bitsPerPixel),
|
||||||
|
BytesPerPixel: uint8(bit.bytesPerPixel),
|
||||||
|
}
|
||||||
|
return bitmap
|
||||||
|
}
|
||||||
|
|
||||||
// GetPortion get portion
|
// GetPortion get portion
|
||||||
func GetPortion(bit C.MMBitmapRef, x, y, w, h C.size_t) C.MMBitmapRef {
|
func GetPortion(bit C.MMBitmapRef, x, y, w, h C.size_t) C.MMBitmapRef {
|
||||||
var rect C.MMRect
|
var rect C.MMRect
|
||||||
|
@ -12,6 +12,7 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"reflect"
|
||||||
|
|
||||||
"github.com/go-vgo/robotgo"
|
"github.com/go-vgo/robotgo"
|
||||||
)
|
)
|
||||||
@ -58,6 +59,11 @@ func aRobotgo() {
|
|||||||
|
|
||||||
robotgo.SaveBitmap(bitmap, "test.png", 1)
|
robotgo.SaveBitmap(bitmap, "test.png", 1)
|
||||||
|
|
||||||
|
var bitmapTest robotgo.Bitmap
|
||||||
|
bitTest := robotgo.OpenBitmap("test.png")
|
||||||
|
bitmapTest = robotgo.ToBitmap(bitTest)
|
||||||
|
fmt.Println("...type", reflect.TypeOf(bitTest), reflect.TypeOf(bitmapTest))
|
||||||
|
|
||||||
// robotgo.MouseClick()
|
// robotgo.MouseClick()
|
||||||
robotgo.ScrollMouse(10, "up")
|
robotgo.ScrollMouse(10, "up")
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user