Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Some links on this page are affiliate links: if you buy through them we may earn a commission, at no extra cost to you.

To capture one running Chrome window, first find its macOS window ID with Quartz Window Services, then capture that ID. A short PyObjC script can do this with Apple’s older, deprecated Quartz image API; for a maintained app, Apple’s newer ScreenCaptureKit is the better foundation. Both approaches require Screen Recording permission, and neither guarantees that every hidden, minimized, protected, or unusual window surface can be captured.

What this method captures—and what it does not

This guide captures a macOS application window belonging to Google Chrome. It does not capture the entire desktop, and it does not address Chrome’s own screenshot features or browser automation. The key distinction is that macOS identifies windows separately from their application owner: enumerate the windows, choose the intended Chrome window, then ask the capture API for that window’s identifier.

A Chrome window can contain multiple tabs, so a window capture records the visible contents of the selected window rather than a separately addressable tab. If several Chrome windows are open, you need a selection rule—such as the displayed window title and a numbered choice. Do not rely on whichever match happens to appear first in the system’s window list.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Apple’s Quartz Window Services can report on-screen windows and their numeric window identifiers, as well as information about offscreen windows. The identifier is commonly exposed as kCGWindowNumber. For a one-off compatibility script, the older CGWindowListCreateImage function can capture by that ID, but Apple marks it deprecated. ScreenCaptureKit is Apple’s modern capture framework for selecting windows or capturing a continuing stream of frames.

#1 Best Overall
Apple 2026 MacBook Neo 13-inch Laptop with A18 Pro chip: Built for AI and Apple Intelligence, Liquid Retina Display, 8GB Unified Memory, 256GB SSD Storage, 1080p FaceTime HD Camera; Blush
  • AN AMAZING MAC AT A SURPRISING PRICE — With an incredibly portable and durable aluminum design, up to 16 hours of battery life,* and the A18 Pro chip, MacBook Neo is ready to go wherever school takes you.
  • FOUR STUNNING COLORS. ONE DURABLE DESIGN — Choose from four beautiful colors — Silver, Blush, Citrus, or Indigo — each with a color-coordinated keyboard. And MacBook Neo is made with a durable recycled aluminum enclosure that helps it reach 60 percent recycled content by weight — the most ever in any Apple product.*
  • FLY THROUGH EVERYDAY ASSIGNMENTS — Whether you’re cramming for finals, using Apple Intelligence* to summarize class notes, creating presentations, or even playing the latest Apple Arcade game,* MacBook Neo delivers the performance and AI capabilities you need to get things done.
  • UP TO 16 HOURS OF BATTERY LIFE — MacBook Neo delivers all day battery life, so you can power through from early morning classes to late night study sessions without worrying about plugging in.
  • A VIBRANT 13-INCH DISPLAY* — The gorgeous Liquid Retina display on MacBook Neo supports 1 billion colors, so photos and videos pop and text is crisp for easy reading.

Choose the capture route

Route Best fit Trade-off
Quartz with CGWindowListCreateImage A short Python script or compatibility task that needs one still image. It is simpler to call from PyObjC, but the image function is deprecated and should not be treated as a future-proof foundation.
ScreenCaptureKit A new application, explicit window filtering, or ongoing frame capture. Python integration is more involved; a small Swift or Objective-C helper is a practical bridge when Python bindings do not expose the needed framework classes.

For an ongoing capture app, ScreenCaptureKit’s model is to request shareable content, identify an SCWindow, create a window-specific SCContentFilter, then either request a still image with SCScreenshotManager or configure an SCStream and process its video sample buffers. Apple’s sample demonstrating that pattern specifies macOS 15 or later and Xcode 16 or later for that sample; those are sample prerequisites, not a universal minimum-version statement for every ScreenCaptureKit API.

Prepare Python and macOS permissions

Install PyObjC

Use a Python environment running on the Mac whose Chrome window you want to capture. Install the PyObjC bridge into that same environment:

python3 -m pip install pyobjc-framework-Quartz pyobjc-framework-Cocoa

The Quartz package exposes the window-list and image APIs used below; Cocoa provides the AppKit bitmap conversion used to write a PNG. If your environment already uses a different PyObjC release, verify the exact names exposed by that version: some dictionary-key constants and Objective-C bridge spellings vary.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #2
Sale
Apple 2026 MacBook Air 13-inch Laptop with M5 chip: Built for AI, 13.6-inch Liquid Retina Display, 16GB Unified Memory, 512GB SSD, 12MP Center Stage Camera, Touch ID, Wi-Fi 7; Midnight
  • BUILT FOR COLLEGE. AND BEYOND — MacBook Air with the M5 chip packs blazing speed and powerful AI capabilities into an incredibly portable design. And with up to 18 hours of battery life,* this thin and light powerhouse is ready to take on almost any major, just about anywhere.
  • TEAR THROUGH TOUGH ASSIGNMENTS — With its faster CPU and unified memory, the M5 chip delivers even more performance and fluidity across apps, making multitasking and creative workflows smooth and responsive. A powerful Neural Engine and next-generation GPU with Neural Accelerators give you a powerful platform for AI.
  • MAKE QUICK WORK OF YOUR TO-DO LIST — Apple Intelligence helps you write, express yourself, and get things done effortlessly — whether it’s for school or everyday life. With groundbreaking privacy protections, it gives you peace of mind that no one else can access your data — not even Apple.*
  • UP TO 18 HOURS OF BATTERY LIFE — MacBook Air delivers incredible battery life with amazing performance, so you can power through a full day of classes without worrying about plugging in.
  • A BRILLIANT 13.6-INCH DISPLAY* — The gorgeous Liquid Retina display on MacBook Air supports 1 billion colors, making photos and videos pop with rich contrast and sharp detail, and text appears supercrisp. So everything — from class presentations to movies to games — looks truly stunning.

Grant Screen Recording access

macOS requires Screen Recording permission for screen-capture operations. When prompted, allow the application that is running the script—often Terminal, an IDE, or a packaged Python app—under System Settings → Privacy & Security → Screen Recording. Apple notes that restarting the capturing app may be necessary after granting access. If you distribute a bundled app, include a clear NSScreenCaptureUsageDescription in its app configuration and request that users enable the app in the same privacy settings.

Find the intended Chrome window

The script below first lists on-screen windows, keeping entries owned by Google Chrome that have a nonempty title and are on the normal application-window layer. It accepts a title filter and a one-based selection number. If multiple windows match, it prints the choices rather than silently choosing the first. The list order is for interaction only; the capture target is the numeric window ID attached to the selected dictionary.

#!/usr/bin/env python3
"""Capture a selected, on-screen Google Chrome window as a PNG."""
import argparse
import sys
from pathlib import Path

import Quartz
from AppKit import NSBitmapImageRep, NSBitmapImageFileTypePNG

OWNER_KEY = "kCGWindowOwnerName"
TITLE_KEY = "kCGWindowName"
LAYER_KEY = "kCGWindowLayer"
NUMBER_KEY = "kCGWindowNumber"


def chrome_windows():
    windows = Quartz.CGWindowListCopyWindowInfo(
        Quartz.kCGWindowListOptionOnScreenOnly,
        Quartz.kCGNullWindowID,
    ) or []
    matches = []
    for window in windows:
        if window.get(OWNER_KEY) != "Google Chrome":
            continue
        if not window.get(TITLE_KEY):
            continue
        # Ordinary application windows normally use layer 0.
        if window.get(LAYER_KEY) != 0:
            continue
        if NUMBER_KEY not in window:
            continue
        matches.append(window)
    return matches


def main():
    parser = argparse.ArgumentParser()
    parser.add_argument("--title", help="keep windows whose title contains this text")
    parser.add_argument("--pick", type=int, help="choose a displayed match, numbered from 1")
    parser.add_argument("--output", default="chrome-window.png")
    args = parser.parse_args()

    windows = chrome_windows()
    if args.title:
        needle = args.title.casefold()
        windows = [w for w in windows if needle in w[TITLE_KEY].casefold()]

    if not windows:
        sys.exit("No matching on-screen Chrome window with a title was found.")

    if len(windows) > 1 and args.pick is None:
        print("More than one Chrome window matches:")
        for index, window in enumerate(windows, start=1):
            print(f"{index}: {window[TITLE_KEY]!r} (ID {window[NUMBER_KEY]})")
        sys.exit("Run again with --pick NUMBER, or narrow the list with --title.")

    choice = args.pick if args.pick is not None else 1
    if choice < 1 or choice > len(windows):
        sys.exit(f"--pick must be between 1 and {len(windows)}.")

    target = windows[choice - 1]
    window_id = target[NUMBER_KEY]
    image = Quartz.CGWindowListCreateImage(
        Quartz.CGRectNull,
        Quartz.kCGWindowListOptionIncludingWindow,
        window_id,
        Quartz.kCGWindowImageBoundsIgnoreFraming,
    )
    if image is None:
        sys.exit("No image returned; check Screen Recording permission and window shareability.")

    width = Quartz.CGImageGetWidth(image)
    height = Quartz.CGImageGetHeight(image)
    if not width or not height:
        sys.exit("The capture returned an image with zero width or height.")

    bitmap = NSBitmapImageRep.alloc().initWithCGImage_(image)
    png = bitmap.representationUsingType_properties_(NSBitmapImageFileTypePNG, {})
    if png is None:
        sys.exit("AppKit could not encode the captured image as PNG.")

    output = Path(args.output)
    if not output.parent.exists():
        sys.exit(f"Output directory does not exist: {output.parent}")
    if not png.writeToFile_atomically_(str(output), True):
        sys.exit(f"Could not write PNG to {output}")
    print(f"Saved {width}x{height} capture of {target[TITLE_KEY]!r} to {output}")


if __name__ == "__main__":
    main()

Save it as capture_chrome.py, then run:

python3 capture_chrome.py
python3 capture_chrome.py --title "Dashboard" --output dashboard.png
python3 capture_chrome.py --pick 2 --output second-window.png

The first command captures automatically only when exactly one window matches. If more than one does, it prints the titles and IDs and exits; use one of the displayed choice numbers on a second run. The title filter is a case-insensitive substring match. It is not a guarantee that the title is unique, so use --pick if multiple windows still match.

Rank #3
Apple 2026 MacBook Neo 13-inch Laptop with A18 Pro chip: Built for AI and Apple Intelligence, Liquid Retina Display, 8GB Unified Memory, 256GB SSD Storage, 1080p FaceTime HD Camera; Indigo
  • AN AMAZING MAC AT A SURPRISING PRICE — With an incredibly portable and durable aluminum design, up to 16 hours of battery life,* and the A18 Pro chip, MacBook Neo is ready to go wherever school takes you.
  • FOUR STUNNING COLORS. ONE DURABLE DESIGN — Choose from four beautiful colors — Silver, Blush, Citrus, or Indigo — each with a color-coordinated keyboard. And MacBook Neo is made with a durable recycled aluminum enclosure that helps it reach 60 percent recycled content by weight — the most ever in any Apple product.*
  • FLY THROUGH EVERYDAY ASSIGNMENTS — Whether you’re cramming for finals, using Apple Intelligence* to summarize class notes, creating presentations, or even playing the latest Apple Arcade game,* MacBook Neo delivers the performance and AI capabilities you need to get things done.
  • UP TO 16 HOURS OF BATTERY LIFE — MacBook Neo delivers all day battery life, so you can power through from early morning classes to late night study sessions without worrying about plugging in.
  • A VIBRANT 13-INCH DISPLAY* — The gorgeous Liquid Retina display on MacBook Neo supports 1 billion colors, so photos and videos pop and text is crisp for easy reading.

What the script does and its limits

Discovery is separate from capture

CGWindowListCopyWindowInfo is called with the on-screen-only option and the null window ID. The returned dictionaries are filtered by owner, nonempty window name, and layer 0 before the script extracts kCGWindowNumber. This makes the target explicit: the code does not assume the first item in the overall system window list is Chrome, or that Chrome has only one window.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Capture and PNG conversion

The still-image call asks for the selected window using kCGWindowListOptionIncludingWindow and kCGWindowImageBoundsIgnoreFraming. It then checks that the result exists and has nonzero dimensions, converts the Core Graphics image to an AppKit bitmap, and writes PNG data. This is an illustrative PyObjC implementation: bindings and constants can differ between releases, so treat any import or selector error as a binding compatibility issue to verify against the installed PyObjC version, not as evidence that every macOS window is capturable.

Why hidden or unusual windows may fail

The code deliberately enumerates on-screen windows. A minimized or otherwise offscreen window may therefore be absent from its candidate list, and a window that closes between enumeration and capture can no longer be captured by its prior ID. Apple defines displays, running apps, and windows as shareable content for ScreenCaptureKit, but shareability and protected-content rules still apply. Results for minimized windows, protected surfaces, and unusual GPU-backed content can vary by macOS release. This script does not silently fall back to a desktop screenshot if the requested window fails.

Rank #4
Apple 2026 MacBook Neo 13-inch Laptop with A18 Pro chip: Built for AI and Apple Intelligence, Liquid Retina Display, 8GB Unified Memory, 256GB SSD Storage, 1080p FaceTime HD Camera; Silver
  • AN AMAZING MAC AT A SURPRISING PRICE — With an incredibly portable and durable aluminum design, up to 16 hours of battery life,* and the A18 Pro chip, MacBook Neo is ready to go wherever school takes you.
  • FOUR STUNNING COLORS. ONE DURABLE DESIGN — Choose from four beautiful colors — Silver, Blush, Citrus, or Indigo — each with a color-coordinated keyboard. And MacBook Neo is made with a durable recycled aluminum enclosure that helps it reach 60 percent recycled content by weight — the most ever in any Apple product.*
  • FLY THROUGH EVERYDAY ASSIGNMENTS — Whether you’re cramming for finals, using Apple Intelligence* to summarize class notes, creating presentations, or even playing the latest Apple Arcade game,* MacBook Neo delivers the performance and AI capabilities you need to get things done.
  • UP TO 16 HOURS OF BATTERY LIFE — MacBook Neo delivers all day battery life, so you can power through from early morning classes to late night study sessions without worrying about plugging in.
  • A VIBRANT 13-INCH DISPLAY* — The gorgeous Liquid Retina display on MacBook Neo supports 1 billion colors, so photos and videos pop and text is crisp for easy reading.

Use ScreenCaptureKit for a maintained application

For a new capture feature, keep interaction and selection in Python if that suits the app, but delegate native capture to a small Swift or Objective-C helper where appropriate. The helper should obtain SCShareableContent, locate the SCWindow corresponding to the chosen Chrome window, create SCContentFilter(desktopIndependentWindow: window), and return an image or frame data to Python. For one image, use SCScreenshotManager; for continuing capture, configure an SCStream, add a screen output, and consume the resulting video sample buffers.

This route is more work than a single PyObjC call, but it uses Apple’s current capture framework and directly models an individual window as the filter. It is a better fit when a project needs ongoing frames or a maintained native capture path. Permission remains part of the design: ask users to grant Screen Recording access to the app that performs capture, explain why it is needed, and make denial or unavailable content an ordinary error path rather than switching to the whole desktop.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Troubleshooting

  • No Chrome window matched: Confirm Chrome is open and the intended window is on-screen with a visible, nonempty title. Remove --title to see whether the substring filter was too restrictive. The script intentionally excludes untitled and nonzero-layer windows.
  • Several matches appear: This is expected with multiple Chrome windows. Narrow by a distinctive title fragment or pass a displayed one-based number using --pick; do not treat the list’s first match as inherently correct.
  • The image is None, empty, or fails to encode: Check Screen Recording permission for the actual process running Python, quit and reopen that app after permission changes, and confirm the selected window is still open and shareable. A protected or unusual surface may remain unavailable.
  • The window disappears after listing: The user or Chrome may close it between discovery and capture. Enumerate again and ask for another selection rather than reusing a stale window ID.
  • Import or selector errors: Confirm both PyObjC framework packages are installed in the interpreter used to run the script. Inspect the dictionary returned by Quartz and the names available in your installed PyObjC version; bridge spellings and constant exposure can vary.
  • Permission was denied or the prompt did not appear: Open System Settings → Privacy & Security → Screen Recording and enable the capturing app. For bundled software, include NSScreenCaptureUsageDescription and explain the capture purpose clearly.

Performance, reliability, and cost considerations

A single window screenshot is a one-time operation, so the Quartz sketch avoids the extra work of maintaining a frame stream. Continuous capture has additional setup and sample-buffer processing; use ScreenCaptureKit’s stream model only when the application needs repeated frames. The API documentation does not establish a universal capture latency or performance number for this script, so measure on the target Mac and workload rather than assuming a fixed speed.

Best Value
Sale
Apple 2025 MacBook Pro Laptop with Apple M5 chip with 10‑core CPU and 10‑core GPU: Built for AI, 14.2-inch Liquid Retina XDR Display, 16GB Unified Memory, 1TB SSD Storage; Space Black
  • SUPERCHARGED BY M5 — The 14-inch MacBook Pro with M5 brings next-generation speed and powerful on-device AI to personal, professional, and creative tasks. Featuring all-day battery life and a breathtaking Liquid Retina XDR display with up to 1600 nits peak brightness, it’s pro in every way.*
  • HAPPILY EVER FASTER — Along with its faster CPU and unified memory, M5 features a more powerful GPU with a Neural Accelerator built into each core, delivering faster AI performance. So you can blaze through demanding workloads at mind-bending speeds.
  • BUILT FOR APPLE INTELLIGENCE — Apple Intelligence is the personal intelligence system that helps you write, express yourself, and get things done effortlessly. With groundbreaking privacy protections, it gives you peace of mind that no one else can access your data — not even Apple.*
  • ALL-DAY BATTERY LIFE — MacBook Pro delivers the same exceptional performance whether it’s running on battery or plugged in.
  • APPS FLY WITH APPLE SILICON — All your favorites, including Microsoft 365 and Adobe Creative Cloud, run lightning fast in macOS.*

Reliability depends on more than a successful API call: the chosen window must still exist, the OS must permit capture, and the content must be shareable. Production software should report these states distinctly, allow reselection after a stale window ID, and test its permission flow and target macOS versions. Because the Quartz image function is deprecated, new long-lived software should plan around ScreenCaptureKit rather than treating this compatibility example as a permanent contract.

The local method uses the Mac’s APIs and has no per-shot service charge described here; the engineering costs are maintaining the Python/native bridge, permission UX, and version coverage. If instead the requirement is a screenshot of a public website by URL—not a particular already-running local Chrome window—a hosted screenshot API is a different solution.

Or skip the browser setup

ScreenshotNeo captures a website from its URL through an API or MCP server; it does not select or capture a Chrome window already open on your Mac. For URL-based site captures, it offers a one-request option:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
import requests

r = requests.get(
    "https://api.screenshotneo.com/v1/shot",
    params={"access_key": "YOUR_API_KEY", "url": "https://stripe.com"},
    timeout=90,
)
open("shot.webp", "wb").write(r.content)

See the ScreenshotNeo API documentation for request options. Before a capture, it accepts cookie or consent banners like a visitor and removes more than 60 known consent platforms, newsletter popups, and chat widgets; each of those steps can be turned off. Bot checks, blank pages, failed loads, timeouts, and cache hits are not billed, and response headers report the page verdict and billing status. Its MCP server gives AI agents tools for screenshots, page information, and PDF capture. The free plan includes 1,000 shots per month with no card; paid plans start at $5 for 3,000 shots.

Sign up for 1,000 free ScreenshotNeo screenshots a month, with no card required.

Frequently Asked Questions

Can this script save JPEG or WebP instead of PNG?

The included conversion path writes PNG. Changing the bitmap encoding requires using a supported AppKit image type and matching the output file extension.

Can a website screenshot API capture the exact Chrome window I already have open?

No. A URL-based screenshot service captures a page from its URL; it does not select a specific local macOS window.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.