From cd7ed72bf247ff88e7661a73b421483067ddac84 Mon Sep 17 00:00:00 2001 From: vcaesar Date: Thu, 27 Jan 2022 10:08:44 -0800 Subject: [PATCH] Add more test code and Update README.md --- README.md | 7 ++++--- robotgo_test.go | 21 +++++++++++++++++++-- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 1b6cecb..7e03083 100644 --- a/README.md +++ b/README.md @@ -312,6 +312,7 @@ import ( "github.com/go-vgo/robotgo" "github.com/vcaesar/gcv" + "github.com/vcaesar/bitmap" ) func main() { @@ -328,10 +329,10 @@ func opencv() { fmt.Println(gcv.FindImgFile(name1, name)) fmt.Println(gcv.FindAllImgFile(name1, name)) - bit := robotgo.OpenBitmap(name1) - defer robotgo.FindBitmap(bit) + bit := bitmap.Open(name1) + defer robotgo.FreeBitmap(bit) fmt.Print("find bitmap: ") - fmt.Println(robotgo.FindBitmap(bit)) + fmt.Println(bitmap.Find(bit)) // bit0 := robotgo.CaptureScreen() // img := robotgo.ToImage(bit0) diff --git a/robotgo_test.go b/robotgo_test.go index 142e8ac..4f882a2 100644 --- a/robotgo_test.go +++ b/robotgo_test.go @@ -59,7 +59,7 @@ func TestMoveMouseSmooth(t *testing.T) { } func TestDragMouse(t *testing.T) { - DragMouse(500, 500) + DragSmooth(500, 500) MilliSleep(50) x, y := GetMousePos() @@ -151,6 +151,23 @@ func TestKeyCode(t *testing.T) { tt.Equal(t, "=", s) } +func TestImage(t *testing.T) { + bit := CaptureScreen() + defer FreeBitmap(bit) + tt.NotNil(t, bit) + + img := ToImage(bit) + err := SavePng(img, "robot_test.png") + tt.Nil(t, err) + + img1 := CaptureImg(10, 10, 20, 20) + e := Save(img1, "robot_img.jpeg", 50) + tt.Nil(t, e) + + tt.Equal(t, 20, Width(img1)) + tt.Equal(t, 20, Height(img1)) +} + func TestPs(t *testing.T) { id, err := Pids() tt.Not(t, "[]", id) @@ -192,6 +209,6 @@ func TestPs(t *testing.T) { // log.Println("tap...") // }() -// i := ShowAlert("t", "msg") +// i := Alert("t", "msg") // tt.Zero(t, i) // }