CGWindowListCreateImage -> ScreenCaptureKit

So I'm building a colour sampler tool, similar to ColorSlurp and since CGWindowListCreateImage (which I am using for below macOS 14.0) is deprecated since Sonoma, I am wondering what's the best approach to replacing it.

The way I use CGWindowListCreateImage currently is to take a screenshot of a specified area around the mouse pointer every time the mouse moves. Which works perfectly fine without issues.

Now I've tried replacing CGWindowListCreateImage with SCScreenshotManager.createImage which is an async function and as you might expect, running async functions on mouse movements doesn't quite work out that well. It is lagging behind, heavily.

So my question would be what's the appropriate ScreenCaptureKit methods to replace the functionality already created with CGWindowListCreateImage? Should I create a SCStream instead? Then I am worried about the fact that I would need to stream the whole screen instead of just the area around the mouse pointer since updating stream configs is an async function as well.

I'd greatly appreciate any sort of direction!

Replies

CGDisplayCreateImageForRect does not appear to be deprecated, could you use that?

  • Ah, guess I could but I imagine they'll deprecate that soon enough as well since they're pushing ScreenCaptureKit pretty heavily. I'm also down the screencapturekit rabbit hole at this point and want to make it work somehow 😅. I'll use that if I can't find another way, cheers!

Add a Comment