Ai
1 Star 0 Fork 1

azhw/robotgo

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
screen.go 1.53 KB
一键复制 编辑 原始数据 按行查看 历史
vz 提交于 2025-04-20 03:54 +08:00 . Update: update import
// Copyright 2016 The go-vgo Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// https://github.com/go-vgo/robotgo/blob/master/LICENSE
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
package robotgo
import (
"image"
// "github.com/kbinani/screenshot"
"github.com/vcaesar/screenshot"
)
// GetDisplayBounds gets the display screen bounds
func GetDisplayBounds(i int) (x, y, w, h int) {
bs := screenshot.GetDisplayBounds(i)
return bs.Min.X, bs.Min.Y, bs.Dx(), bs.Dy()
}
// GetDisplayRect gets the display rect
func GetDisplayRect(i int) Rect {
x, y, w, h := GetDisplayBounds(i)
return Rect{
Point{X: x, Y: y},
Size{W: w, H: h}}
}
// Capture capture the screenshot, use the CaptureImg default
func Capture(args ...int) (*image.RGBA, error) {
displayId := 0
if DisplayID != -1 {
displayId = DisplayID
}
if len(args) > 4 {
displayId = args[4]
}
var x, y, w, h int
if len(args) > 3 {
x, y, w, h = args[0], args[1], args[2], args[3]
} else {
x, y, w, h = GetDisplayBounds(displayId)
}
return screenshot.Capture(x, y, w, h)
}
// SaveCapture capture screen and save the screenshot to image
func SaveCapture(path string, args ...int) error {
img, err := CaptureImg(args...)
if err != nil {
return err
}
return Save(img, path)
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/azhw/robotgo.git
git@gitee.com:azhw/robotgo.git
azhw
robotgo
robotgo
master

搜索帮助