Merge pull request #451 from go-vgo/bitmap-pr

Add more test code and Update README.md
This commit is contained in:
Evans 2022-01-27 10:12:20 -08:00 committed by GitHub
commit e81c9ec843
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 23 additions and 5 deletions

View File

@ -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)

View File

@ -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)
// }