mirror of
https://github.com/go-vgo/robotgo.git
synced 2025-06-01 14:43:55 +00:00
Merge pull request #451 from go-vgo/bitmap-pr
Add more test code and Update README.md
This commit is contained in:
commit
e81c9ec843
@ -312,6 +312,7 @@ import (
|
|||||||
|
|
||||||
"github.com/go-vgo/robotgo"
|
"github.com/go-vgo/robotgo"
|
||||||
"github.com/vcaesar/gcv"
|
"github.com/vcaesar/gcv"
|
||||||
|
"github.com/vcaesar/bitmap"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
@ -328,10 +329,10 @@ func opencv() {
|
|||||||
fmt.Println(gcv.FindImgFile(name1, name))
|
fmt.Println(gcv.FindImgFile(name1, name))
|
||||||
fmt.Println(gcv.FindAllImgFile(name1, name))
|
fmt.Println(gcv.FindAllImgFile(name1, name))
|
||||||
|
|
||||||
bit := robotgo.OpenBitmap(name1)
|
bit := bitmap.Open(name1)
|
||||||
defer robotgo.FindBitmap(bit)
|
defer robotgo.FreeBitmap(bit)
|
||||||
fmt.Print("find bitmap: ")
|
fmt.Print("find bitmap: ")
|
||||||
fmt.Println(robotgo.FindBitmap(bit))
|
fmt.Println(bitmap.Find(bit))
|
||||||
|
|
||||||
// bit0 := robotgo.CaptureScreen()
|
// bit0 := robotgo.CaptureScreen()
|
||||||
// img := robotgo.ToImage(bit0)
|
// img := robotgo.ToImage(bit0)
|
||||||
|
@ -59,7 +59,7 @@ func TestMoveMouseSmooth(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestDragMouse(t *testing.T) {
|
func TestDragMouse(t *testing.T) {
|
||||||
DragMouse(500, 500)
|
DragSmooth(500, 500)
|
||||||
MilliSleep(50)
|
MilliSleep(50)
|
||||||
x, y := GetMousePos()
|
x, y := GetMousePos()
|
||||||
|
|
||||||
@ -151,6 +151,23 @@ func TestKeyCode(t *testing.T) {
|
|||||||
tt.Equal(t, "=", s)
|
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) {
|
func TestPs(t *testing.T) {
|
||||||
id, err := Pids()
|
id, err := Pids()
|
||||||
tt.Not(t, "[]", id)
|
tt.Not(t, "[]", id)
|
||||||
@ -192,6 +209,6 @@ func TestPs(t *testing.T) {
|
|||||||
// log.Println("tap...")
|
// log.Println("tap...")
|
||||||
// }()
|
// }()
|
||||||
|
|
||||||
// i := ShowAlert("t", "msg")
|
// i := Alert("t", "msg")
|
||||||
// tt.Zero(t, i)
|
// tt.Zero(t, i)
|
||||||
// }
|
// }
|
||||||
|
Loading…
Reference in New Issue
Block a user