From 2c870bb7a002336a623d11de0fcbf07738ac1ea0 Mon Sep 17 00:00:00 2001 From: vCaesar Date: Sun, 2 Jul 2017 12:01:07 +0800 Subject: [PATCH] Add README.md and update version --- examples/README.md | 147 +++++++++++++++++++++++++++++++++++++++++++++ robotgo.go | 2 +- 2 files changed, 148 insertions(+), 1 deletion(-) create mode 100644 examples/README.md diff --git a/examples/README.md b/examples/README.md new file mode 100644 index 0000000..c998b78 --- /dev/null +++ b/examples/README.md @@ -0,0 +1,147 @@ +# Robotgo examples + +## Install: +``` +go get -u github.com/go-vgo/robotgo +``` + +## [Examples:](https://github.com/go-vgo/robotgo/blob/master/examples) + +#### [Mouse](https://github.com/go-vgo/robotgo/blob/master/examples/mouse/main.go) + +```Go +package main + +import ( + "github.com/go-vgo/robotgo" +) + +func main() { + robotgo.ScrollMouse(10, "up") + robotgo.MouseClick("left", true) + robotgo.MoveMouseSmooth(100, 200, 1.0, 100.0) +} +``` + +#### [Keyboard](https://github.com/go-vgo/robotgo/blob/master/examples/key/main.go) + +```Go +package main + +import ( + "fmt" + "github.com/go-vgo/robotgo" +) + +func main() { + robotgo.TypeString("Hello World") + robotgo.KeyTap("enter") + robotgo.TypeString("en") + robotgo.KeyTap("i", "alt", "command") + arr := []string{"alt", "command"} + robotgo.KeyTap("i", arr) + + robotgo.WriteAll("测试") + text, err := robotgo.ReadAll() + if err == nil { + fmt.Println(text) + } +} +``` + +#### [Screen](https://github.com/go-vgo/robotgo/blob/master/examples/screen/main.go) + +```Go +package main + +import ( + "fmt" + + "github.com/go-vgo/robotgo" +) + +func main() { + x, y := robotgo.GetMousePos() + fmt.Println("pos:", x, y) + color := robotgo.GetPixelColor(100, 200) + fmt.Println("color----", color) +} +``` + +#### [Bitmap](https://github.com/go-vgo/robotgo/blob/master/examples/bitmap/mian.go) + +```Go +package main + +import ( + "fmt" + + "github.com/go-vgo/robotgo" +) + +func main() { + bitmap := robotgo.CaptureScreen(10, 20, 30, 40) + fmt.Println("...", bitmap) + + fx, fy := robotgo.FindBitmap(bitmap) + fmt.Println("FindBitmap------", fx, fy) + + robotgo.SaveBitmap(bitmap, "test.png") +} +``` + +#### [Event](https://github.com/go-vgo/robotgo/blob/master/examples/event/main.go) + +```Go +package main + +import ( + "fmt" + + "github.com/go-vgo/robotgo" +) + +func main() { + keve := robotgo.AddEvent("k") + if keve == 0 { + fmt.Println("you press...", "k") + } + + mleft := robotgo.AddEvent("mleft") + if mleft == 0 { + fmt.Println("you press...", "mouse left button") + } +} +``` + +#### [Window](https://github.com/go-vgo/robotgo/blob/master/examples/window/main.go) + +```Go +package main + +import ( + "fmt" + + "github.com/go-vgo/robotgo" +) + +func main() { + fpid, err := robotgo.FindIds("Google") + if err == nil { + fmt.Println("pids...", fpid) + } + + isExist, err := robotgo.PidExists(100) + if err == nil { + fmt.Println("pid exists is", isExist) + } + + abool := robotgo.ShowAlert("test", "robotgo") + if abool == 0 { + fmt.Println("ok@@@", "ok") + } + + title := robotgo.GetTitle() + fmt.Println("title@@@", title) +} +``` diff --git a/robotgo.go b/robotgo.go index c54c664..19b9fc9 100644 --- a/robotgo.go +++ b/robotgo.go @@ -55,7 +55,7 @@ import ( ) const ( - version string = "v0.45.0.346, Mount Kailash!" + version string = "v0.45.0.353, Mount Qomolangma!" ) // GetVersion get version