However it's not in v2.9 (as of right now the latest) so I just added this file to my local module. Pillow has since added ImageGrab support for macOS! Screenshot("/tmp/testscreenshot_partial.png", region=region) # Capture region (100x100 box from top-left) ![]() Screenshot("/tmp/testscreenshot_full.png") # finalize the CGImageDestination object. # When all the images (only 1 in this example) are added to the destination, Quartz.CGImageDestinationAddImage(dest, image, properties) # Add the image to the destination, characterizing the image with The default region is CG.CGRectInfinite (captures the full screen)ĭpi = 72 # FIXME: Should query this from somewhere, e.g for retina displaysĭest = Quartz.CGImageDestinationCreateWithURL( """region should be a CGRect, something like: If you don't need to do that, I'd recommend just calling the screencapture command (more features, more robust, and quicker - the initial PyObjC import alone can take around a second) import Quartz ![]() You can capture the entire screen, or specify a region to capture. Here's how to capture and save a screenshot with PyObjC, based on my answer here
0 Comments
Leave a Reply. |