Small ScreenCaptureKit fixes

This commit is contained in:
AuroraWright
2024-12-21 04:06:45 +01:00
parent 975bd0ace9
commit d9cf93f636
2 changed files with 5 additions and 3 deletions

View File

@@ -614,7 +614,7 @@ class OCRSpace:
res = res.json() res = res.json()
if type(res) == str: if isinstance(res, str):
return (False, 'Unknown error!') return (False, 'Unknown error!')
if res['IsErroredOnProcessing']: if res['IsErroredOnProcessing']:
return (False, res['ErrorMessage']) return (False, res['ErrorMessage'])

View File

@@ -42,8 +42,8 @@ try:
import objc import objc
import platform import platform
from AppKit import NSData, NSImage, NSBitmapImageRep, NSDeviceRGBColorSpace, NSGraphicsContext, NSZeroPoint, NSZeroRect, NSCompositingOperationCopy from AppKit import NSData, NSImage, NSBitmapImageRep, NSDeviceRGBColorSpace, NSGraphicsContext, NSZeroPoint, NSZeroRect, NSCompositingOperationCopy
from Quartz import CGWindowListCreateImageFromArray, kCGWindowImageBoundsIgnoreFraming, CGRectNull, CGMainDisplayID, CGWindowListCopyWindowInfo, CGWindowListCreateDescriptionFromArray, \ from Quartz import CGWindowListCreateImageFromArray, kCGWindowImageBoundsIgnoreFraming, CGRectMake, CGRectNull, CGMainDisplayID, CGWindowListCopyWindowInfo, \
kCGWindowListOptionOnScreenOnly, kCGWindowListExcludeDesktopElements, kCGWindowName, kCGNullWindowID, \ CGWindowListCreateDescriptionFromArray, kCGWindowListOptionOnScreenOnly, kCGWindowListExcludeDesktopElements, kCGWindowName, kCGNullWindowID, \
CGImageGetWidth, CGImageGetHeight, CGDataProviderCopyData, CGImageGetDataProvider, CGImageGetBytesPerRow CGImageGetWidth, CGImageGetHeight, CGDataProviderCopyData, CGImageGetDataProvider, CGImageGetBytesPerRow
from ScreenCaptureKit import SCContentFilter, SCScreenshotManager, SCShareableContent, SCStreamConfiguration, SCCaptureResolutionBest from ScreenCaptureKit import SCContentFilter, SCScreenshotManager, SCShareableContent, SCStreamConfiguration, SCCaptureResolutionBest
except ImportError: except ImportError:
@@ -254,10 +254,12 @@ def capture_macos_window_screenshot(window_id):
width = frame.size.width * scale width = frame.size.width * scale
height = frame.size.height * scale height = frame.size.height * scale
configuration = SCStreamConfiguration.alloc().init() configuration = SCStreamConfiguration.alloc().init()
configuration.setSourceRect_(CGRectMake(0, 0, frame.size.width, frame.size.height))
configuration.setWidth_(width) configuration.setWidth_(width)
configuration.setHeight_(height) configuration.setHeight_(height)
configuration.setShowsCursor_(False) configuration.setShowsCursor_(False)
configuration.setCaptureResolution_(SCCaptureResolutionBest) configuration.setCaptureResolution_(SCCaptureResolutionBest)
configuration.setIgnoreGlobalClipSingleWindow_(True)
SCScreenshotManager.captureImageWithFilter_configuration_completionHandler_( SCScreenshotManager.captureImageWithFilter_configuration_completionHandler_(
content_filter, configuration, capture_image_completion_handler content_filter, configuration, capture_image_completion_handler