mirror of
https://github.com/go-vgo/robotgo.git
synced 2025-06-01 14:43: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"
|
||||
)
|
||||
|
||||
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")
|
||||
|
@ -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()
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user