From 3f4b0f987251a2a1885a35a17db04bb087231021 Mon Sep 17 00:00:00 2001 From: eric Date: Tue, 18 Jun 2024 20:20:04 +0800 Subject: [PATCH 1/2] capture error --- robotgo.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/robotgo.go b/robotgo.go index f4660ac..68a2456 100644 --- a/robotgo.go +++ b/robotgo.go @@ -46,6 +46,7 @@ package robotgo import "C" import ( + "errors" "image" "runtime" "time" @@ -360,11 +361,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 From 932a918e44fa392de137688bef7a1ae036ed8932 Mon Sep 17 00:00:00 2001 From: eric Date: Tue, 18 Jun 2024 20:27:53 +0800 Subject: [PATCH 2/2] aohanhongzhi --- go.mod | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go.mod b/go.mod index ab3bfe9..fc76051 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module github.com/go-vgo/robotgo +module github.com/aohanhongzhi/robotgo go 1.17