mirror of
https://github.com/go-vgo/robotgo.git
synced 2025-05-31 06:13:55 +00:00
35 lines
607 B
Go
35 lines
607 B
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/go-vgo/robotgo"
|
|
)
|
|
|
|
func colorPicker() {
|
|
// click the left mouse button to get the value
|
|
m := robotgo.AddEvent("mleft")
|
|
if m {
|
|
x, y := robotgo.GetMousePos()
|
|
fmt.Println("mouse pos: ", x, y)
|
|
|
|
clo := robotgo.GetPixelColor(x, y)
|
|
fmt.Println("color: #", clo)
|
|
|
|
// clipboard
|
|
s1 := fmt.Sprint(x, ", ", y) + ": " + "#" + clo
|
|
err := robotgo.WriteAll(s1)
|
|
if err != nil {
|
|
fmt.Println("clipboard err: ", err)
|
|
}
|
|
}
|
|
}
|
|
|
|
func main() {
|
|
fmt.Println("color picker: ")
|
|
fmt.Println("click the left mouse button to get the value.")
|
|
for {
|
|
colorPicker()
|
|
}
|
|
}
|