Go语言:屏幕操作(go-vgo/robotgo)
李大钊:我们要八小时工作!八小时睡觉!另外的八小时留给自己!
▌前置安装:
1
| go get github.com/go-vgo/robotgo
|
▌代码实例:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
| package main
import ( "github.com/go-vgo/robotgo" )
func main() {
color := robotgo.GetPixelColor(800, 400) println(`颜色:`, color)
width, height := robotgo.GetScreenSize() println(`宽:`, width, ` 高:`, height)
bitmap := robotgo.CaptureScreen(0, 0, 800, 400)
robotgo.SaveBitmap(bitmap, `screen.png`) }
|
转载:https://zhuanlan.zhihu.com/p/140482402