diff --git a/screen.go b/screen.go index 9f8b28ad..1e23bba7 100644 --- a/screen.go +++ b/screen.go @@ -11,6 +11,7 @@ package robotgo import ( + "errors" "image" "github.com/kbinani/screenshot" @@ -53,9 +54,9 @@ func Capture(args ...int) (*image.RGBA, error) { // SaveCapture capture screen and save the screenshot to image func SaveCapture(path string, args ...int) error { - img, err := Capture(args...) - if err != nil { - return err + img := CaptureImg(args...) + if img == nil { + return errors.New("Capture image not found") } return Save(img, path) diff --git a/screen/goScreen.h b/screen/goScreen.h index d4349a5a..1d93d075 100644 --- a/screen/goScreen.h +++ b/screen/goScreen.h @@ -12,7 +12,6 @@ #include "../base/pubs.h" #include "../base/rgb.h" #include "screengrab_c.h" -#include "screen_c.h" #include void padHex(MMRGBHex color, char* hex) { diff --git a/screen/screengrab_c.h b/screen/screengrab_c.h index 32c30f7c..579c3802 100644 --- a/screen/screengrab_c.h +++ b/screen/screengrab_c.h @@ -13,6 +13,7 @@ #elif defined(IS_WINDOWS) #include #endif +#include "screen_c.h" #if defined(IS_MACOSX) && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ > MAC_OS_VERSION_14_4 static CGImageRef capture15(CGDirectDisplayID id, CGRect diIntersectDisplayLocal, CGColorSpaceRef colorSpace) { @@ -39,9 +40,12 @@ SCContentFilter* filter = [[SCContentFilter alloc] initWithDisplay:target excludingWindows:@[]]; SCStreamConfiguration* config = [[SCStreamConfiguration alloc] init]; + config.queueDepth = 5; config.sourceRect = diIntersectDisplayLocal; - config.width = diIntersectDisplayLocal.size.width; - config.height = diIntersectDisplayLocal.size.height; + config.width = diIntersectDisplayLocal.size.width * sys_scale(id); + config.height = diIntersectDisplayLocal.size.height * sys_scale(id); + config.scalesToFit = false; + config.captureResolution = 1; [SCScreenshotManager captureImageWithFilter:filter configuration:config