diff --git a/go.mod b/go.mod index e9879ee..1467e9e 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module github.com/go-vgo/robotgo +module github.com/aohanhongzhi/robotgo go 1.22 diff --git a/robotgo.go b/robotgo.go index 4057b28..b7b6888 100644 --- a/robotgo.go +++ b/robotgo.go @@ -50,6 +50,7 @@ package robotgo import "C" import ( + "errors" "image" "runtime" "time" @@ -366,11 +367,14 @@ func CaptureGo(args ...int) Bitmap { } // CaptureImg capture the screen and return image.Image -func CaptureImg(args ...int) image.Image { +func CaptureImg(args ...int) (image.Image, error) { bit := CaptureScreen(args...) + if bit == nil { + return nil, errors.New("capture error") + } defer FreeBitmap(bit) - return ToImage(bit) + return ToImage(bit), nil } // FreeBitmap free and dealloc the C bitmap