From 9468b8fdde856293fc6f868caec6ce2a8d9fcd5d Mon Sep 17 00:00:00 2001 From: vcaesar Date: Mon, 13 Sep 2021 12:28:23 -0400 Subject: [PATCH] Update README.md and example --- README.md | 22 ++++++++++++++++++++-- README_zh.md | 23 +++++++++++++++++++++-- examples/screen/main.go | 2 +- 3 files changed, 42 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 6e1e30e..9b82400 100644 --- a/README.md +++ b/README.md @@ -130,6 +130,11 @@ import ( func main() { robotgo.ScrollMouse(10, "up") + robotgo.Scroll(100, 200) + + robotgo.MoveMouse(10, 10) + robotgo.Drag(10, 10) + robotgo.MouseClick("left", true) robotgo.MoveMouseSmooth(100, 200, 1.0, 100.0) } @@ -189,6 +194,9 @@ func main() { color := robotgo.GetPixelColor(100, 200) fmt.Println("color---- ", color) + + sx, sy := robotgo.GetScreenSize() + fmt.Println("get screen size: ", sx, sy) } ``` @@ -208,9 +216,19 @@ func main() { // use `defer robotgo.FreeBitmap(bit)` to free the bitmap defer robotgo.FreeBitmap(bitmap) - fmt.Println("...", bitmap) + fmt.Println("bitmap...", bitmap) + img := robotgo.ToImage(bitmap) + robotgo.SavePng(img, "test_1.png") - fx, fy := robotgo.FindBitmap(bitmap) + bit2 := robotgo.ToCBitmap(robotgo.ImgToBitmap(img)) + fx, fy := robotgo.FindBitmap(bit2) + fmt.Println("FindBitmap------ ", fx, fy) + + arr := robotgo.FindEveryBitmap(bit2) + fmt.Println("Find every bitmap: ", arr) + robotgo.SaveBitmap(bitmap, "test.png") + + fx, fy = robotgo.FindBitmap(bitmap) fmt.Println("FindBitmap------ ", fx, fy) robotgo.SaveBitmap(bitmap, "test.png") diff --git a/README_zh.md b/README_zh.md index 5938b4c..ce80829 100644 --- a/README_zh.md +++ b/README_zh.md @@ -128,6 +128,11 @@ import ( func main() { robotgo.ScrollMouse(10, "up") + robotgo.Scroll(100, 200) + + robotgo.MoveMouse(10, 10) + robotgo.Drag(10, 10) + robotgo.MouseClick("left", true) robotgo.MoveMouseSmooth(100, 200, 1.0, 100.0) } @@ -187,6 +192,9 @@ func main() { color := robotgo.GetPixelColor(100, 200) fmt.Println("color----", color) + + sx, sy := robotgo.GetScreenSize() + fmt.Println("get screen size: ", sx, sy) } ``` @@ -205,9 +213,20 @@ func main() { bitmap := robotgo.CaptureScreen(10, 20, 30, 40) // use `defer robotgo.FreeBitmap(bit)` to free the bitmap defer robotgo.FreeBitmap(bitmap) - fmt.Println("...", bitmap) + + fmt.Println("bitmap...", bitmap) + img := robotgo.ToImage(bitmap) + robotgo.SavePng(img, "test_1.png") - fx, fy := robotgo.FindBitmap(bitmap) + bit2 := robotgo.ToCBitmap(robotgo.ImgToBitmap(img)) + fx, fy := robotgo.FindBitmap(bit2) + fmt.Println("FindBitmap------ ", fx, fy) + + arr := robotgo.FindEveryBitmap(bit2) + fmt.Println("Find every bitmap: ", arr) + robotgo.SaveBitmap(bitmap, "test.png") + + fx, fy = robotgo.FindBitmap(bitmap) fmt.Println("FindBitmap------", fx, fy) robotgo.SaveBitmap(bitmap, "test.png") diff --git a/examples/screen/main.go b/examples/screen/main.go index 123c428..53fdb00 100644 --- a/examples/screen/main.go +++ b/examples/screen/main.go @@ -63,7 +63,7 @@ func screen() { // gets the screen width and height sx, sy := robotgo.GetScreenSize() - fmt.Println("...", sx, sy) + fmt.Println("get screen size: ", sx, sy) color() }