mirror of
https://github.com/go-vgo/robotgo.git
synced 2025-06-01 06:33:56 +00:00
update examples and remove useless function
This commit is contained in:
parent
401c700580
commit
b9836d769a
@ -26,8 +26,8 @@ func main() {
|
||||
robotgo.TypeString("Hello World")
|
||||
|
||||
robotgo.TypeString("留给真爱你的人")
|
||||
robotgo.TypeStr("留给真爱你的人")
|
||||
ustr := uint32(robotgo.CharCodeAt("留给真爱你的人", 0))
|
||||
robotgo.TypeStr("所以, 你好, 再见")
|
||||
ustr := uint32(robotgo.CharCodeAt("所以, 你好, 再见", 0))
|
||||
robotgo.UnicodeType(ustr)
|
||||
|
||||
robotgo.PasteStr("粘贴字符串, paste")
|
||||
|
@ -26,8 +26,8 @@ func key() {
|
||||
robotgo.TypeString("Hello World")
|
||||
|
||||
robotgo.TypeString("留给真爱你的人")
|
||||
robotgo.TypeStr("留给真爱你的人")
|
||||
ustr := uint32(robotgo.CharCodeAt("留给真爱你的人", 0))
|
||||
robotgo.TypeStr("所以, 你好, 再见")
|
||||
ustr := uint32(robotgo.CharCodeAt("所以, 你好, 再见", 0))
|
||||
robotgo.UnicodeType(ustr)
|
||||
|
||||
robotgo.PasteStr("粘贴字符串, paste")
|
||||
@ -118,6 +118,8 @@ func screen() {
|
||||
|
||||
abitMap := robotgo.CaptureScreen()
|
||||
fmt.Println("abitMap...", abitMap)
|
||||
gbit := robotgo.ToBitmap(abitMap)
|
||||
fmt.Println("bitmap...", gbit.Width)
|
||||
|
||||
gbitMap := robotgo.GoCaptureScreen()
|
||||
fmt.Println("GoCaptureScreen...", gbitMap.Width)
|
||||
|
@ -24,6 +24,8 @@ func main() {
|
||||
|
||||
abitMap := robotgo.CaptureScreen()
|
||||
fmt.Println("abitMap...", abitMap)
|
||||
gbit := robotgo.ToBitmap(abitMap)
|
||||
fmt.Println("bitmap...", gbit.Width)
|
||||
|
||||
gbitMap := robotgo.GoCaptureScreen()
|
||||
fmt.Println("GoCaptureScreen...", gbitMap.Width)
|
||||
|
84
robotgo.go
84
robotgo.go
@ -276,43 +276,43 @@ func GoCaptureScreen(args ...int) Bitmap {
|
||||
}
|
||||
|
||||
// BCaptureScreen capture the screen and return bitmap(go struct), Wno-deprecated
|
||||
func BCaptureScreen(args ...int) Bitmap {
|
||||
var (
|
||||
x C.size_t
|
||||
y C.size_t
|
||||
w C.size_t
|
||||
h C.size_t
|
||||
)
|
||||
// func BCaptureScreen(args ...int) Bitmap {
|
||||
// var (
|
||||
// x C.size_t
|
||||
// y C.size_t
|
||||
// w C.size_t
|
||||
// h C.size_t
|
||||
// )
|
||||
|
||||
Try(func() {
|
||||
x = C.size_t(args[0])
|
||||
y = C.size_t(args[1])
|
||||
w = C.size_t(args[2])
|
||||
h = C.size_t(args[3])
|
||||
}, func(e interface{}) {
|
||||
// fmt.Println("err:::", e)
|
||||
x = 0
|
||||
y = 0
|
||||
//Get screen size.
|
||||
var displaySize C.MMSize
|
||||
displaySize = C.getMainDisplaySize()
|
||||
w = displaySize.width
|
||||
h = displaySize.height
|
||||
})
|
||||
// Try(func() {
|
||||
// x = C.size_t(args[0])
|
||||
// y = C.size_t(args[1])
|
||||
// w = C.size_t(args[2])
|
||||
// h = C.size_t(args[3])
|
||||
// }, func(e interface{}) {
|
||||
// // fmt.Println("err:::", e)
|
||||
// x = 0
|
||||
// y = 0
|
||||
// //Get screen size.
|
||||
// var displaySize C.MMSize
|
||||
// displaySize = C.getMainDisplaySize()
|
||||
// w = displaySize.width
|
||||
// h = displaySize.height
|
||||
// })
|
||||
|
||||
bit := C.capture_screen(x, y, w, h)
|
||||
// fmt.Println("...", bit)
|
||||
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),
|
||||
}
|
||||
// bit := C.capture_screen(x, y, w, h)
|
||||
// // fmt.Println("...", bit)
|
||||
// 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
|
||||
}
|
||||
// return bitmap
|
||||
// }
|
||||
|
||||
// SaveCapture capture screen and save
|
||||
func SaveCapture(spath string, args ...int) {
|
||||
@ -1156,15 +1156,15 @@ func StopEvent() {
|
||||
}
|
||||
|
||||
// LEvent add event listener, Wno-deprecated
|
||||
func LEvent(aeve string) int {
|
||||
cs := C.CString(aeve)
|
||||
eve := C.add_event(cs)
|
||||
// fmt.Println("event@@", eve)
|
||||
geve := int(eve)
|
||||
defer C.free(unsafe.Pointer(cs))
|
||||
// func LEvent(aeve string) int {
|
||||
// cs := C.CString(aeve)
|
||||
// eve := C.add_event(cs)
|
||||
// // fmt.Println("event@@", eve)
|
||||
// geve := int(eve)
|
||||
// defer C.free(unsafe.Pointer(cs))
|
||||
|
||||
return geve
|
||||
}
|
||||
// return geve
|
||||
// }
|
||||
|
||||
/*
|
||||
____ __ ____ __ .__ __. _______ ______ ____ __ ____
|
||||
|
Loading…
Reference in New Issue
Block a user