mirror of
https://github.com/go-vgo/robotgo.git
synced 2025-06-02 23:23:55 +00:00
Refactoring screen and event example code
This commit is contained in:
parent
0b009ab521
commit
36e220b7a1
@ -17,11 +17,7 @@ import (
|
|||||||
// "go-vgo/robotgo"
|
// "go-vgo/robotgo"
|
||||||
)
|
)
|
||||||
|
|
||||||
func event() {
|
func add() {
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// Global event listener
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
fmt.Println("--- Please press v---")
|
fmt.Println("--- Please press v---")
|
||||||
eve := robotgo.AddEvent("v")
|
eve := robotgo.AddEvent("v")
|
||||||
|
|
||||||
@ -40,6 +36,14 @@ func event() {
|
|||||||
if feve == 0 {
|
if feve == 0 {
|
||||||
fmt.Println("You press...", "f1")
|
fmt.Println("You press...", "f1")
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func event() {
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Global event listener
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
add()
|
||||||
|
|
||||||
fmt.Println("--- Please press left mouse button---")
|
fmt.Println("--- Please press left mouse button---")
|
||||||
mleft := robotgo.AddEvent("mleft")
|
mleft := robotgo.AddEvent("mleft")
|
||||||
|
@ -17,11 +17,7 @@ import (
|
|||||||
// "go-vgo/robotgo"
|
// "go-vgo/robotgo"
|
||||||
)
|
)
|
||||||
|
|
||||||
func screen() {
|
func bitmap() {
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// Read the screen
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
abitMap := robotgo.CaptureScreen()
|
abitMap := robotgo.CaptureScreen()
|
||||||
fmt.Println("abitMap...", abitMap)
|
fmt.Println("abitMap...", abitMap)
|
||||||
gbit := robotgo.ToBitmap(abitMap)
|
gbit := robotgo.ToBitmap(abitMap)
|
||||||
@ -32,11 +28,9 @@ func screen() {
|
|||||||
// fmt.Println("...", gbitmap.Width, gbitmap.BytesPerPixel)
|
// fmt.Println("...", gbitmap.Width, gbitmap.BytesPerPixel)
|
||||||
|
|
||||||
robotgo.SaveCapture("saveCapture.png", 10, 20, 100, 100)
|
robotgo.SaveCapture("saveCapture.png", 10, 20, 100, 100)
|
||||||
|
}
|
||||||
|
|
||||||
// gets the screen width and height
|
func color() {
|
||||||
sx, sy := robotgo.GetScreenSize()
|
|
||||||
fmt.Println("...", sx, sy)
|
|
||||||
|
|
||||||
// gets the pixel color at 100, 200.
|
// gets the pixel color at 100, 200.
|
||||||
color := robotgo.GetPixelColor(100, 200)
|
color := robotgo.GetPixelColor(100, 200)
|
||||||
fmt.Println("color----", color, "-----------------")
|
fmt.Println("color----", color, "-----------------")
|
||||||
@ -60,6 +54,20 @@ func screen() {
|
|||||||
fmt.Println("color---", color2)
|
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() {
|
func main() {
|
||||||
screen()
|
screen()
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user