Update md and Update example

This commit is contained in:
vCaesar 2017-01-24 23:16:12 +08:00
parent 50a74fa4a5
commit 8f911409b1
3 changed files with 63 additions and 43 deletions

View File

@ -16,11 +16,8 @@ RobotGo supports Mac, Windows, and Linux(X11).
This is a work in progress.
##[API Document](https://github.com/go-vgo/robotgo/blob/master/docs/doc.md)    [中文文档](https://github.com/go-vgo/robotgo/blob/master/docs/doc_zh.md)
Please click API Document;This is a work in progress.
##Contents
- [API Docs](#API-Docs)
- [Requirements](#requirements)
- [Installation](#installation)
- [Update](#update)
@ -28,29 +25,37 @@ This is a work in progress.
- [Future](#future)
- [Contributors](#contributors)
###Requirements:
##API-Docs
####ALL:
[API Document](https://github.com/go-vgo/robotgo/blob/master/docs/doc.md)    [中文文档](https://github.com/go-vgo/robotgo/blob/master/docs/doc_zh.md)
This is a work in progress.
##Requirements:
Now,Please make sure Golang,GCC,zlib and libpng is installed correctly before installing RobotGo.
###ALL:
```
Golang
//Gcc
Gcc
zlib & libpng (bitmap)
```
####For Mac OS X:
###For Mac OS X:
Xcode Command Line Tools
```
brew install libpng
brew install homebrew/dupes/zlib
```
####For Windows:
###For Windows:
```
MinGW or other GCC
```
#####[zlib&libpng Windows32 GCC's Course](https://github.com/go-vgo/Mingw32)
####[zlib&libpng Windows32 GCC's Course](https://github.com/go-vgo/Mingw32)
#####[Download include zlib&libpng Windows64 GCC](https://github.com/go-vgo/Mingw)
####[Download include zlib&libpng Windows64 GCC](https://github.com/go-vgo/Mingw)
####For everything else:
###For everything else:
```
GCC
@ -61,7 +66,7 @@ Event:
xcb,xkb,libxkbcommon
```
#####Ubuntu:
####Ubuntu:
```yml
sudo apt-get install libx11-dev
@ -133,16 +138,16 @@ func main() {
package main
import (
. "fmt"
"fmt"
"github.com/go-vgo/robotgo"
)
func main() {
x, y := robotgo.GetMousePos()
Println("pos:", x, y)
fmt.Println("pos:", x, y)
color := robotgo.GetPixelColor(100, 200)
Println("color----", color)
fmt.Println("color----", color)
}
```
@ -152,17 +157,17 @@ func main() {
package main
import (
. "fmt"
"fmt"
"github.com/go-vgo/robotgo"
)
func main() {
bit_map := robotgo.CaptureScreen(10, 20, 30, 40)
Println("...", bit_map)
fmt.Println("...", bit_map)
fx, fy := robotgo.FindBitmap(bit_map)
Println("FindBitmap------", fx, fy)
fmt.Println("FindBitmap------", fx, fy)
robotgo.SaveBitmap(bit_map, "test.png")
}
@ -174,7 +179,7 @@ func main() {
package main
import (
. "fmt"
"fmt"
"github.com/go-vgo/robotgo"
)
@ -182,12 +187,12 @@ import (
func main() {
keve := robotgo.AddEvent("k")
if keve == 0 {
Println("you press...", "k")
fmt.Println("you press...", "k")
}
mleft := robotgo.AddEvent("mleft")
if mleft == 0 {
Println("you press...", "mouse left button")
fmt.Println("you press...", "mouse left button")
}
}
```
@ -198,7 +203,7 @@ func main() {
package main
import (
. "fmt"
"fmt"
"github.com/go-vgo/robotgo"
)
@ -206,18 +211,19 @@ import (
func main() {
abool := robotgo.ShowAlert("test", "robotgo")
if abool == 0 {
Println("ok@@@", "ok")
fmt.Println("ok@@@", "ok")
}
title := robotgo.GetTitle()
Println("title@@@", title)
fmt.Println("title@@@", title)
}
```
##Future
- Update Find an image on screen, read pixels from an image
- Update Window Handle
- Try support Android,maybe support IOS.
- Try support Android,maybe support IOS
- Remove zlib/libpng dependencies
##Contributors

View File

@ -212,7 +212,8 @@ func main() {
##Future
- Update Find an image on screen, read pixels from an image
- Update Window Handle
- Try support Android,maybe support IOS.
- Try support Android,maybe support IOS
- Remove zlib/libpng dependencies
##Contributors

View File

@ -18,14 +18,16 @@ import (
)
func main() {
//Control the keyboard
////////////////////////////////////////////////////////////////////////////////
// Control the keyboard
////////////////////////////////////////////////////////////////////////////////
robotgo.TypeString("Hello World") //importing "Hello World"
robotgo.KeyTap("enter") //Press "enter"
robotgo.KeyTap("a", "control")
robotgo.KeyTap("h", "command") //Hide window
robotgo.KeyTap("i", "alt", "command")
//Press "i", "alt", "command" Key combination
robotgo.KeyTap("i", "alt", "command")
arr := []string{"alt", "command"}
robotgo.KeyTap("i", arr)
@ -39,7 +41,9 @@ func main() {
robotgo.KeyToggle("enter", "down")
robotgo.TypeString("en")
//Control the mouse
////////////////////////////////////////////////////////////////////////////////
// Control the mouse
////////////////////////////////////////////////////////////////////////////////
robotgo.MoveMouse(100, 200) //Move the mouse to 100, 200
robotgo.MouseClick() //Click the left mouse button
robotgo.MouseClick("right", false) //Click the right mouse button
@ -63,55 +67,62 @@ func main() {
robotgo.MoveMouse(800, i)
}
//read the screen
////////////////////////////////////////////////////////////////////////////////
// Read the screen
////////////////////////////////////////////////////////////////////////////////
gbitMap := robotgo.BCaptureScreen()
fmt.Println("BCaptureScreen...", gbitMap.Width)
// fmt.Println("...", gbitmap.Width, gbitmap.BytesPerPixel)
sx, sy := robotgo.GetScreenSize()
//Gets the screen width and height
sx, sy := robotgo.GetScreenSize()
fmt.Println("...", sx, sy)
color := robotgo.GetPixelColor(100, 200)
//Gets the pixel color at 100, 200.
color := robotgo.GetPixelColor(100, 200)
fmt.Println("color----", color, "-----------------")
color2 := robotgo.GetPixelColor(10, 20)
//Gets the pixel color at 10, 20.
color2 := robotgo.GetPixelColor(10, 20)
fmt.Println("color---", color2)
////////////////////////////////////////////////////////////////////////////////
// Bitmap
abitMap := robotgo.CaptureScreen()
////////////////////////////////////////////////////////////////////////////////
//Gets all of the screen
abitMap := robotgo.CaptureScreen()
fmt.Println("abitMap...", abitMap)
bitmap := robotgo.CaptureScreen(100, 200, 30, 40) //Gets part of the screen
//Gets part of the screen
bitmap := robotgo.CaptureScreen(100, 200, 30, 40)
fmt.Println("CaptureScreen...", bitmap)
fx, fy := robotgo.FindBitmap(bitmap)
//Searches for needle in bitmap
fx, fy := robotgo.FindBitmap(bitmap)
fmt.Println("FindBitmap------", fx, fy)
bitpos := robotgo.GetPortion(bitmap, 10, 10, 11, 10)
//Returns new bitmap object created from a portion of another
bitpos := robotgo.GetPortion(bitmap, 10, 10, 11, 10)
fmt.Println(bitpos)
//Creates bitmap from string by bitmap
bitstr := robotgo.TostringBitmap(bitmap)
//Creates bitmap from string by bit_map
fmt.Println("bitstr...", bitstr)
// sbitmap := robotgo.BitmapFromstring(bitstr, 2)
// fmt.Println("...", sbitmap)
robotgo.SaveBitmap(bitmap, "test.png")
//Saves image to absolute filepath in the given format
robotgo.SaveBitmap(bitmap, "test.png")
robotgo.SaveBitmap(bitmap, "test31.tif", 1)
robotgo.Convert("test.png", "test.tif") //Convert image
openbit := robotgo.OpenBitmap("test.tif") // open image bitmap
fmt.Println("openBitmap...", openbit)
//global event listener
////////////////////////////////////////////////////////////////////////////////
// Global event listener
////////////////////////////////////////////////////////////////////////////////
fmt.Println("---please press v---")
eve := robotgo.AddEvent("v")
@ -145,7 +156,9 @@ func main() {
//Stop AddEvent
// robotgo.StopEvent()
//Window Handle
////////////////////////////////////////////////////////////////////////////////
// Window Handle
////////////////////////////////////////////////////////////////////////////////
abool := robotgo.ShowAlert("hello", "robotgo") //Show Alert Window
if abool == 0 {
fmt.Println("ok@@@", "ok")