Update example

This commit is contained in:
vCaesar 2017-01-16 17:23:32 +08:00
parent 8fb24a222f
commit 8948a606b3

View File

@ -11,7 +11,6 @@
package main package main
import ( import (
// . "fmt"
"fmt" "fmt"
"github.com/go-vgo/robotgo" "github.com/go-vgo/robotgo"
@ -66,7 +65,8 @@ func main() {
//read the screen //read the screen
gbitMap := robotgo.BCaptureScreen() gbitMap := robotgo.BCaptureScreen()
fmt.Println("Capture_Screen...", gbitMap.Width) fmt.Println("BCaptureScreen...", gbitMap.Width)
// fmt.Println("...", gbitmap.Width, gbitmap.BytesPerPixel)
sx, sy := robotgo.GetScreenSize() sx, sy := robotgo.GetScreenSize()
//Gets the screen width and height //Gets the screen width and height
@ -83,12 +83,10 @@ func main() {
// Bitmap // Bitmap
abitMap := robotgo.CaptureScreen() abitMap := robotgo.CaptureScreen()
//Gets all of the screen //Gets all of the screen
fmt.Println("a...", abitMap) fmt.Println("abitMap...", abitMap)
bitmap := robotgo.CaptureScreen(100, 200, 30, 40) bitmap := robotgo.CaptureScreen(100, 200, 30, 40) //Gets part of the screen
//Gets part of the screen
fmt.Println("CaptureScreen...", bitmap) fmt.Println("CaptureScreen...", bitmap)
// Println("...", bit_map.Width, bit_map.BytesPerPixel)
fx, fy := robotgo.FindBitmap(bitmap) fx, fy := robotgo.FindBitmap(bitmap)
//Searches for needle in bitmap //Searches for needle in bitmap
@ -100,21 +98,18 @@ func main() {
bitstr := robotgo.TostringBitmap(bitmap) bitstr := robotgo.TostringBitmap(bitmap)
//Creates bitmap from string by bit_map //Creates bitmap from string by bit_map
fmt.Println("bit_str...", bitstr) fmt.Println("bitstr...", bitstr)
// sbitmap := robotgo.BitmapFromstring(bit_str, 2) // sbitmap := robotgo.BitmapFromstring(bitstr, 2)
// Println("...", sbitmap) // fmt.Println("...", sbitmap)
robotgo.SaveBitmap(bitmap, "test.png") robotgo.SaveBitmap(bitmap, "test.png")
//Saves image to absolute filepath in the given format //Saves image to absolute filepath in the given format
robotgo.SaveBitmap(bitmap, "test31.tif", 1) robotgo.SaveBitmap(bitmap, "test31.tif", 1)
robotgo.Convert("test.png", "test.tif") robotgo.Convert("test.png", "test.tif") //Convert image
//Convert image
// open_bit := robotgo.OpenBitmap("test.tif") openbit := robotgo.OpenBitmap("test.tif") // open image bitmap
openbit := robotgo.OpenBitmap("test.tif") fmt.Println("openBitmap...", openbit)
// open image bitmap
fmt.Println("open...", openbit)
//global event listener //global event listener
fmt.Println("---please press v---") fmt.Println("---please press v---")
@ -142,10 +137,10 @@ func main() {
fmt.Println("---you press left mouse button---", "mleft") fmt.Println("---you press left mouse button---", "mleft")
} }
// mright := robotgo.AddEvent("mright") mright := robotgo.AddEvent("mright")
// if mright == 0 { if mright == 0 {
// Println("---you press right mouse button---", "mright") fmt.Println("---you press right mouse button---", "mright")
// } }
//Stop AddEvent //Stop AddEvent
// robotgo.StopEvent() // robotgo.StopEvent()