Refactoring screen and event example code

This commit is contained in:
vcaesar 2018-10-07 12:23:50 -04:00
parent 0b009ab521
commit 36e220b7a1
2 changed files with 26 additions and 14 deletions

View File

@ -17,11 +17,7 @@ import (
// "go-vgo/robotgo"
)
func event() {
////////////////////////////////////////////////////////////////////////////////
// Global event listener
////////////////////////////////////////////////////////////////////////////////
func add() {
fmt.Println("--- Please press v---")
eve := robotgo.AddEvent("v")
@ -40,6 +36,14 @@ func event() {
if feve == 0 {
fmt.Println("You press...", "f1")
}
}
func event() {
////////////////////////////////////////////////////////////////////////////////
// Global event listener
////////////////////////////////////////////////////////////////////////////////
add()
fmt.Println("--- Please press left mouse button---")
mleft := robotgo.AddEvent("mleft")

View File

@ -17,11 +17,7 @@ import (
// "go-vgo/robotgo"
)
func screen() {
////////////////////////////////////////////////////////////////////////////////
// Read the screen
////////////////////////////////////////////////////////////////////////////////
func bitmap() {
abitMap := robotgo.CaptureScreen()
fmt.Println("abitMap...", abitMap)
gbit := robotgo.ToBitmap(abitMap)
@ -32,11 +28,9 @@ func screen() {
// fmt.Println("...", gbitmap.Width, gbitmap.BytesPerPixel)
robotgo.SaveCapture("saveCapture.png", 10, 20, 100, 100)
}
// gets the screen width and height
sx, sy := robotgo.GetScreenSize()
fmt.Println("...", sx, sy)
func color() {
// gets the pixel color at 100, 200.
color := robotgo.GetPixelColor(100, 200)
fmt.Println("color----", color, "-----------------")
@ -60,6 +54,20 @@ func screen() {
fmt.Println("color---", color2)
}
func screen() {
////////////////////////////////////////////////////////////////////////////////
// Read the screen
////////////////////////////////////////////////////////////////////////////////
bitmap()
// gets the screen width and height
sx, sy := robotgo.GetScreenSize()
fmt.Println("...", sx, sy)
color()
}
func main() {
screen()
}