Add README.md and update version

This commit is contained in:
vCaesar 2017-07-02 12:01:07 +08:00
parent 7ac679bf89
commit 2c870bb7a0
2 changed files with 148 additions and 1 deletions

147
examples/README.md Normal file
View File

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

View File

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