update examples and remove useless function

This commit is contained in:
vcaesar 2018-01-27 01:28:02 +08:00
parent 401c700580
commit b9836d769a
4 changed files with 50 additions and 46 deletions

View File

@ -26,8 +26,8 @@ func main() {
robotgo.TypeString("Hello World") robotgo.TypeString("Hello World")
robotgo.TypeString("留给真爱你的人") robotgo.TypeString("留给真爱你的人")
robotgo.TypeStr("留给真爱你的人") robotgo.TypeStr("所以, 你好, 再见")
ustr := uint32(robotgo.CharCodeAt("留给真爱你的人", 0)) ustr := uint32(robotgo.CharCodeAt("所以, 你好, 再见", 0))
robotgo.UnicodeType(ustr) robotgo.UnicodeType(ustr)
robotgo.PasteStr("粘贴字符串, paste") robotgo.PasteStr("粘贴字符串, paste")

View File

@ -26,8 +26,8 @@ func key() {
robotgo.TypeString("Hello World") robotgo.TypeString("Hello World")
robotgo.TypeString("留给真爱你的人") robotgo.TypeString("留给真爱你的人")
robotgo.TypeStr("留给真爱你的人") robotgo.TypeStr("所以, 你好, 再见")
ustr := uint32(robotgo.CharCodeAt("留给真爱你的人", 0)) ustr := uint32(robotgo.CharCodeAt("所以, 你好, 再见", 0))
robotgo.UnicodeType(ustr) robotgo.UnicodeType(ustr)
robotgo.PasteStr("粘贴字符串, paste") robotgo.PasteStr("粘贴字符串, paste")
@ -118,6 +118,8 @@ func screen() {
abitMap := robotgo.CaptureScreen() abitMap := robotgo.CaptureScreen()
fmt.Println("abitMap...", abitMap) fmt.Println("abitMap...", abitMap)
gbit := robotgo.ToBitmap(abitMap)
fmt.Println("bitmap...", gbit.Width)
gbitMap := robotgo.GoCaptureScreen() gbitMap := robotgo.GoCaptureScreen()
fmt.Println("GoCaptureScreen...", gbitMap.Width) fmt.Println("GoCaptureScreen...", gbitMap.Width)

View File

@ -24,6 +24,8 @@ func main() {
abitMap := robotgo.CaptureScreen() abitMap := robotgo.CaptureScreen()
fmt.Println("abitMap...", abitMap) fmt.Println("abitMap...", abitMap)
gbit := robotgo.ToBitmap(abitMap)
fmt.Println("bitmap...", gbit.Width)
gbitMap := robotgo.GoCaptureScreen() gbitMap := robotgo.GoCaptureScreen()
fmt.Println("GoCaptureScreen...", gbitMap.Width) fmt.Println("GoCaptureScreen...", gbitMap.Width)

View File

@ -276,43 +276,43 @@ func GoCaptureScreen(args ...int) Bitmap {
} }
// BCaptureScreen capture the screen and return bitmap(go struct), Wno-deprecated // BCaptureScreen capture the screen and return bitmap(go struct), Wno-deprecated
func BCaptureScreen(args ...int) Bitmap { // func BCaptureScreen(args ...int) Bitmap {
var ( // var (
x C.size_t // x C.size_t
y C.size_t // y C.size_t
w C.size_t // w C.size_t
h C.size_t // h C.size_t
) // )
Try(func() { // Try(func() {
x = C.size_t(args[0]) // x = C.size_t(args[0])
y = C.size_t(args[1]) // y = C.size_t(args[1])
w = C.size_t(args[2]) // w = C.size_t(args[2])
h = C.size_t(args[3]) // h = C.size_t(args[3])
}, func(e interface{}) { // }, func(e interface{}) {
// fmt.Println("err:::", e) // // fmt.Println("err:::", e)
x = 0 // x = 0
y = 0 // y = 0
//Get screen size. // //Get screen size.
var displaySize C.MMSize // var displaySize C.MMSize
displaySize = C.getMainDisplaySize() // displaySize = C.getMainDisplaySize()
w = displaySize.width // w = displaySize.width
h = displaySize.height // h = displaySize.height
}) // })
bit := C.capture_screen(x, y, w, h) // bit := C.capture_screen(x, y, w, h)
// fmt.Println("...", bit) // // fmt.Println("...", bit)
bitmap := Bitmap{ // bitmap := Bitmap{
ImageBuffer: (*uint8)(bit.imageBuffer), // ImageBuffer: (*uint8)(bit.imageBuffer),
Width: int(bit.width), // Width: int(bit.width),
Height: int(bit.height), // Height: int(bit.height),
Bytewidth: int(bit.bytewidth), // Bytewidth: int(bit.bytewidth),
BitsPerPixel: uint8(bit.bitsPerPixel), // BitsPerPixel: uint8(bit.bitsPerPixel),
BytesPerPixel: uint8(bit.bytesPerPixel), // BytesPerPixel: uint8(bit.bytesPerPixel),
} // }
return bitmap // return bitmap
} // }
// SaveCapture capture screen and save // SaveCapture capture screen and save
func SaveCapture(spath string, args ...int) { func SaveCapture(spath string, args ...int) {
@ -1156,15 +1156,15 @@ func StopEvent() {
} }
// LEvent add event listener, Wno-deprecated // LEvent add event listener, Wno-deprecated
func LEvent(aeve string) int { // func LEvent(aeve string) int {
cs := C.CString(aeve) // cs := C.CString(aeve)
eve := C.add_event(cs) // eve := C.add_event(cs)
// fmt.Println("event@@", eve) // // fmt.Println("event@@", eve)
geve := int(eve) // geve := int(eve)
defer C.free(unsafe.Pointer(cs)) // defer C.free(unsafe.Pointer(cs))
return geve // return geve
} // }
/* /*
____ __ ____ __ .__ __. _______ ______ ____ __ ____ ____ __ ____ __ .__ __. _______ ______ ____ __ ____