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.

PyAutoGUI captures a screen area, not a window identified by its title. To capture one application window, first find its current screen coordinates, then pass its left edge, top edge, width, and height to pyautogui.screenshot(region=(left, top, width, height)). The rectangle you choose controls whether the title bar and borders appear.

Capture a window by its screen coordinates

PyAutoGUI’s screenshot() function accepts a four-integer region tuple: left, top, width, and height. It returns a Pillow image that you can save with save(). Use screen coordinates for the target display and make sure width and height are positive.

import pyautogui

# Replace these example values with the target window's current bounds.
left, top, width, height = 100, 80, 900, 600
image = pyautogui.screenshot(region=(left, top, width, height))
image.save("window.png")

The example coordinates are illustrative, not a measured window position. To save directly to a file, you can also provide a filename to screenshot():

import pyautogui

pyautogui.screenshot("window.png", region=(100, 80, 900, 600))

The official PyAutoGUI screenshot documentation describes region as a tuple of left, top, width, and height for capturing less than the entire screen.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Philips 24 Inch Computer Monitor FHD 100Hz VA VESA Flicker-Free, 241V8LB
  • CRISP CLARITY: This 23.8″ Philips V line monitor delivers crisp Full HD 1920x1080 visuals. Enjoy movies, shows and videos with remarkable detail
  • INCREDIBLE CONTRAST: The VA panel produces brighter whites and deeper blacks. You get true-to-life images and more gradients with 16.7 million colors
  • THE PERFECT VIEW: The 178/178 degree extra wide viewing angle prevents the shifting of colors when viewed from an offset angle, so you always get consistent colors
  • WORK SEAMLESSLY: This sleek monitor is virtually bezel-free on three sides, so the screen looks even bigger for the viewer. This minimalistic design also allows for seamless multi-monitor setups that enhance your workflow and boost productivity
  • A BETTER READING EXPERIENCE: For busy office workers, EasyRead mode provides a more paper-like experience for when viewing lengthy documents

Find the window bounds before capturing

The central challenge is getting a reliable rectangle. PyAutoGUI’s project overview documents locating, moving, resizing, maximizing, minimizing, and closing application windows as Windows-only functionality; it does not document a portable, title-based window lookup API. On Windows, a window-information library can enumerate windows and expose their bounds. On macOS and Linux, use an appropriate native accessibility or window-management API, or another compatible library, then pass the resulting rectangle to PyAutoGUI.

Windows: look up a window title with PyGetWindow

PyGetWindow’s documentation shows window enumeration and information access. Install the packages with:

python -m pip install pyautogui pygetwindow

For example, enumerate windows and inspect the matching title and rectangle:

import PyGetWindow as gw

for window in gw.getAllWindows():
    if "Calculator" in window.title:
        print(window.title, window.left, window.top,
              window.width, window.height)

Use the bounds of the intended window in the screenshot call. The title match above is a simple substring example: if several windows contain the same text, add stricter matching or select the intended window explicitly. Check that the window is visible and not minimized before capturing; a minimized window may not occupy the expected screen area.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #2
Philips 22 Inch Computer Monitor FHD 100Hz VA VESA Flicker-Free, 221V8LB
  • CRISP CLARITY: This 22 inch class (21.5″ viewable) Philips V line monitor delivers crisp Full HD 1920x1080 visuals. Enjoy movies, shows and videos with remarkable detail
  • 100HZ FAST REFRESH RATE: 100Hz brings your favorite movies and video games to life. Stream, binge, and play effortlessly
  • SMOOTH ACTION WITH ADAPTIVE-SYNC: Adaptive-Sync technology ensures fluid action sequences and rapid response time. Every frame will be rendered smoothly with crystal clarity and without stutter
  • INCREDIBLE CONTRAST: The VA panel produces brighter whites and deeper blacks. You get true-to-life images and more gradients with 16.7 million colors
  • THE PERFECT VIEW: The 178/178 degree extra wide viewing angle prevents the shifting of colors when viewed from an offset angle, so you always get consistent colors

macOS and Linux: use a desktop-specific window API

Do not assume the Windows title lookup example works unchanged on macOS or Linux. Obtain the bounds using an OS-specific API or compatible library, and verify that the desktop environment permits screen capture and window inspection. Linux behavior can depend on the display server and its policy; in particular, confirm whether your setup is using X11 or Wayland and whether the chosen integration supports it. On macOS, allow the relevant application screen-recording permissions if requested.

Choose which parts of the window to include

The coordinates define a rectangle on the screen, not a semantic “window content” region. If the bounds include the title bar and borders, the screenshot includes them. If you need only the client area, obtain or calculate that inner rectangle using the window API rather than assuming the outer frame dimensions are the content dimensions.

  • Full window: use the outer window bounds when the title bar and frame are useful context.
  • Client area: use the content-area bounds if the output should omit decorations. The exact method for obtaining these bounds depends on the operating system and window library.
  • Partial view: adjust left, top, width, or height to capture a specific portion of the window.

Window borders, display scaling, multiple monitors, and operating-system coordinate conventions can affect the rectangle. Validate the resulting image in the target environment instead of assuming that a coordinate obtained on one machine will transfer unchanged to another.

Keep captures accurate when a window moves

A rectangle becomes stale if its window is moved or resized. For a stable layout, you can obtain the bounds once and reuse them. For a window that may move, reacquire its bounds before each capture or whenever your automation detects movement. Avoid caching coordinates indefinitely unless you control the window’s position and size.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
Sale
Dell 24 Monitor - SE2426H - 23.8-inch FHD (1920x1080) 144Hz 1ms Display, in-Plane Switching (IPS) Technology, AMD FreeSync™, TÜV 3-Star 2X HDMI, Tilt
  • Clear visuals. Fluid motion: A 144Hz refresh rate and 1ms MPRT deliver smooth, tear‑free motion across work, gaming, and streaming for clearer, more fluid viewing.
  • Eye comfort: TÜV Rheinland 3‑star* certification reduces harmful blue light while preserving stunning color quality without compromise. *TÜV Rheinland 3-star eye comfort certification.
  • Wide viewing angle: Get consistent views across a wide 178° /178° viewing angle.
  • In-Plane Switching (IPS): See excellent color accuracy and consistency across wide viewing angles with In-plane Switching (IPS) technology.
  • Ultra-thin bezels: Maximize your viewing experience with thin bezels.

Locate a window by a visual template

If title-based discovery is unavailable or unreliable, PyAutoGUI can search for an image on the screen. The locate functions return a bounding box when a match is found. Restricting the search to a smaller area can reduce work and help avoid matching a similar object elsewhere on the screen.

import pyautogui

try:
    box = pyautogui.locateOnScreen("window_marker.png", confidence=0.9)
except pyautogui.ImageNotFoundException:
    box = None

if box is None:
    raise RuntimeError("Window marker was not found")

image = pyautogui.screenshot(region=(box.left, box.top,
                                     box.width, box.height))
image.save("window.png")

Use a distinctive template image that is visible at the target screen scale. The confidence option requires OpenCV; without it, omit that argument. A visual match identifies the matched image region, which may be only a marker rather than the entire application window. If you need the full window, use the match to locate it and then determine the complete window rectangle.

PyAutoGUI’s screenshot and locate documentation notes that locate calls can raise ImageNotFoundException when no match is found. It gives an approximate one-to-two-second duration for locate calls on a 1920×1080 screen, compared with roughly 100 milliseconds for a full-screen screenshot at that resolution. Those are documentation approximations, not guarantees for every machine or capture region.

Install and verify screenshot dependencies

Install PyAutoGUI in the Python environment that will run your script:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #4
Samsung 27" Essential S3 (S36GD) Series FHD 1800R Curved Computer Monitor
  • CURVED FOR ENHANCED ENGAGEMENT: An immersive viewing experience with a curved monitor that wraps more closely around your field of vision; It creates a wider view, enhancing depth perception and minimizing peripheral distraction
  • SMOOTH PERFORMANCE FOR SEAMLESS CONTENT: Stay in the action when playing games, watching videos, or working on creative projects; The 100Hz refresh rate reduces lag and motion blur so you don't miss a thing in fast-paced moments¹
  • MORE GAMING POWER: Gain the edge with optimizable game settings; Color and image contrast can be adjusted to see scenes more vividly and spot enemies hiding in the dark; Game Mode adjusts any game to fill the screen so you can view every detail²
  • KEEP IT EASY ON THE EYES: Care for your eyes and stay comfortable, even during long sessions; Advanced eye comfort technology certified by TÜV reduces eye strain by minimizing blue light and reducing irritating screen flicker²
  • INCREASED VERSATILITY: Connect to more; Plug devices straight into your monitor for increased flexibility, making your computing environment even more convenient
python -m pip install pyautogui

PyAutoGUI uses Pillow for image data. Its screenshot documentation lists scrot as required for Linux screenshot support and identifies macOS’s screencapture command as the system capture utility. The installation documentation also lists dependencies, including PyGetWindow. Follow the relevant platform setup and confirm that the capture utility is available in the environment running Python.

Or skip the browser setup

PyAutoGUI is for capturing a local desktop window. If what you actually need is a screenshot of a public web page, ScreenshotNeo can capture the page with one HTTP request instead of locating a browser window and calculating screen coordinates. Its API can return PNG, JPEG, WebP, or PDF; clean-up options remove supported consent banners, newsletter popups, and chat widgets before capture.

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp

See the ScreenshotNeo API documentation for request options and response details. Bot checks, blank pages, timeouts, failed loads, and cache hits cost nothing; responses identify the page verdict and billing status in headers. ScreenshotNeo also provides an MCP server with screenshot tools for AI agents, and its Free plan includes 1,000 shots per month without a card. Paid plans start at $5 for 3,000 shots. Sign up for ScreenshotNeo’s free plan.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Troubleshoot common capture problems

The screenshot shows the wrong part of the screen

Check the tuple order: it is (left, top, width, height), not left, top, right, bottom. Print the window bounds immediately before capture and compare them with the actual screen position. Then check display scaling and whether the coordinates refer to the same monitor and coordinate space as the capture utility.

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

The title bar appears, or the content is clipped

This follows from the rectangle you supplied. Use the outer bounds to include decorations, or obtain the client-area rectangle to exclude them. If content is clipped, confirm that the window was not resized after its bounds were read and that your width and height cover the desired area.

Best Value
Sceptre New 22-Inch Gaming Monitor, FHD 1080p, Up to 144Hz, HDMI, DisplayPort, Built-in Speakers, Machine Black (E225W-FW144 Series, 2026)
  • 【INTEGRATED SPEAKERS】Whether you're at work or in the midst of an intense gaming session, our built-in speakers provide rich and seamless audio, all while keeping your desk clutter-free.
  • 【EASY ON THE EYES】 Protect your eyes and enhance your comfort with Blue-Light Shift technology. This feature reduces harmful blue light emissions from your screen, helping to alleviate eye strain during long hours of use and promoting healthier viewing habits.
  • 【WIDEN YOUR PERSPECTIVE】Our sleek minimal bezel design ensures undivided attention. The nearly bezel-free display seamlessly connects in a dual monitor arrangement, delivering an unobstructed view that lets you focus on more at once, completely distraction-free.

The window cannot be found by title

Verify the exact visible title and whether it changes with the open document or page. A substring search can match multiple windows or none. On non-Windows systems, use a desktop-appropriate lookup method instead of relying on PyAutoGUI for title discovery.

A visual locate call finds nothing

Make sure the template is visible, distinctive, and captured at a compatible scale. Search the correct screen region and handle ImageNotFoundException as a normal no-match outcome. If using confidence, install OpenCV; otherwise remove the parameter.

Linux capture fails

Confirm that Pillow and the required screenshot utility scrot are installed, and check whether your display server and desktop policy permit capture. A setup that works under one Linux display configuration may not work under another.

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

macOS capture is blocked

Check the application’s Screen Recording permission in macOS privacy settings, then retry. Permission changes may require restarting the application that runs Python.

Performance and reliability trade-offs

Capturing a known rectangle avoids the extra screen-search step and is the better fit when the window is stationary or its bounds are readily available. Visual location can adapt to an unknown position, but it adds latency and depends on a usable template. PyAutoGUI’s documentation estimates roughly 100 milliseconds for a 1920×1080 screenshot and about one or two seconds for locate calls on that screen size; actual times depend on environment and workload.

For repeated captures, reuse bounds only while the window remains in place. Refresh them after a move, resize, monitor change, or display-layout change. For unattended automation, handle missing windows, permission failures, unavailable Linux capture utilities, and visual no-match results explicitly rather than saving an image as if every capture succeeded.

Frequently Asked Questions

Can PyAutoGUI capture a window directly from its title?

PyAutoGUI’s portable screenshot API takes screen coordinates; title-based window discovery is not documented as a cross-platform PyAutoGUI feature.

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

What order does the screenshot region tuple use?

Use (left, top, width, height).

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.