按下 s 键就会把当前鼠标所在位置的颜色复制到剪贴板...
代码只有几行
package main
import (
"github.com/atotto/clipboard"
"github.com/go-vgo/robotgo"
)
func main() {
mleft := robotgo.AddEvent("s")
if mleft == 0 {
color := robotgo.GetPixelColor(robotgo.GetMousePos())
clipboard.WriteAll("#"+color)
}
}
1
jprovim 2019-05-30 02:19:33 +08:00
```
package main import ( "fmt" "github.com/atotto/clipboard" "github.com/go-vgo/robotgo" ) func main() { mleft := robotgo.AddEvent("s") if mleft { fmt.Println("add events...") color := robotgo.GetPixelColor(robotgo.GetMousePos()) clipboard.WriteAll("#"+color) } } ``` 保存 a.go ``` go get ... go build a.go ./a // CTRL + C to quit ``` |