Crashes, No Sound, or Screen Glitches?
Random freezes, missing sound and display glitches usually trace back to one bad driver. Find and replace yours safely.Free scan · under a minutePC Slower Than It Used to Be?
A free scan shows the junk files, broken settings and background clutter dragging Windows down - then fixes them in one click.Free scan · Windows 10 & 11Use pyautogui.screenshot() to capture the current desktop. It returns a Pillow image, accepts a filename for immediate saving, and can limit the capture with region=(left, top, width, height). Install PyAutoGUI first with python3 -m pip install pyautogui; on Linux, also install the scrot command.
Install PyAutoGUI and its screenshot dependencies
Create and activate a virtual environment if this script belongs to a project, then install the package:
python3 -m pip install pyautogui
PyAutoGUI documents support for Windows, macOS and Linux. Screenshot capture uses Pillow, which is installed as a dependency. Linux also needs the scrot executable:
sudo apt-get install scrot
Run that command on Debian- or Ubuntu-based systems. On another Linux distribution, install its equivalent screenshot backend through the distribution’s package manager. If Pillow or the Linux backend is missing, your Python code can be correct and still fail before an image is returned.
Free tools Windows power users keep installed
One-click scans. No signup required.
#1 Best Overall
- Compatible with Nintendo Switch 2’s new GameChat mode
- Crisp HD 720p/30 fps video calls with diagonal 55° field of view and auto light correction. Compatible with popular platforms including Skype and Zoom.
- The built-in noise-reducing mic makes sure your voice comes across clearly up to 1.5 meters away, even if you’re in busy surroundings.
- C270’s RightLight 2 feature adjusts to lighting conditions, producing brighter, contrasted images to help you look good in all your conference calls.
- The adjustable universal clip lets you attach the camera securely to your screen or laptop, or fold the clip and set the webcam on a shelf. You’re always ready for your next video call.
Check that Python can import the library
python3 -c "import pyautogui; print(pyautogui.__version__)"
Run the test from the same environment that will execute your script. A global installation and a virtual-environment installation are different locations, so an import may succeed in one shell and fail in another.
Capture and save the entire display
The shortest working example captures the visible desktop and writes a PNG:
import pyautogui
image = pyautogui.screenshot("screen.png")
print(image.size)
Passing "screen.png" makes PyAutoGUI save the image while capturing it. The call still returns the Pillow Image object, so image.size, image processing, or a second save can follow immediately.
You can also capture first and choose the output path afterward:
from pathlib import Path
import pyautogui
image = pyautogui.screenshot()
output = Path("captures") / "screen.png"
output.parent.mkdir(parents=True, exist_ok=True)
image.save(output)
print(f"Saved {output.resolve()}")
This second form is useful when the filename depends on a timestamp, run number, or other result calculated after capture. Pillow determines the format from the filename extension in normal use; the examples use PNG because it preserves desktop text and edges without lossy compression.
Rank #2
- Compatible with Nintendo Switch 2’s new GameChat mode
- Auto-Light Balance: RightLight boosts brightness by up to 50%, reducing shadows so you look your best—compared to previous-generation Logitech webcams (1)
- Privacy with a Slide: The integrated webcam cover makes it easy to get total, reliable privacy when you're not on a video call
- Built-In Mic: The built-in microphone lets others hear you clearly during video calls
- Easy Plug-And-Play: The Brio 101 works with most video calling platforms, including Microsoft Teams, Zoom and Google Meet—no hassle; it just works
Capture only part of the screen
Pass a four-item tuple to region:
import pyautogui
# left, top, width, height
crop = pyautogui.screenshot(region=(0, 0, 300, 400))
crop.save("crop.png")
The coordinates are in screen pixels. left and top identify the rectangle’s upper-left corner; width and height describe its size. A region of (0, 0, 300, 400) therefore captures the first 300 pixels horizontally and 400 pixels vertically from the desktop origin.
Build a reusable region function
from pathlib import Path
import pyautogui
def save_region(path: str, left: int, top: int, width: int, height: int) -> None:
if width <= 0 or height <= 0:
raise ValueError("width and height must be positive")
image = pyautogui.screenshot(region=(left, top, width, height))
Path(path).parent.mkdir(parents=True, exist_ok=True)
image.save(path)
save_region("captures/panel.png", 100, 80, 800, 600)
Limiting the rectangle reduces the amount of image data your program has to hold and process. It is also safer for workflows that only need one panel, dialog, or chart rather than the whole desktop.
Coordinate mistakes to avoid
- Use a positive width and height; a zero-sized rectangle cannot produce a useful image.
- Measure coordinates in the desktop’s pixel coordinate system, not browser CSS pixels or document coordinates.
- Capture after the target window has become visible. PyAutoGUI screenshots represent the desktop output rather than a web page’s source.
- For a repeatable workflow, keep the window position and display arrangement stable, or calculate the rectangle from a known layout.
Choose direct saving or post-capture saving
| Method | Example | Best when |
|---|---|---|
| Save during capture | pyautogui.screenshot("screen.png") |
You already know the final path and want the fewest lines. |
| Save afterward | image = pyautogui.screenshot(); image.save("screen.png") |
You need to inspect, crop, annotate, rename, or encode the returned Pillow image first. |
Both forms perform the same desktop capture. The difference is when you select the output path and whether you retain the image object for additional operations.
Make a reliable capture script
A small delay lets a user or automation step finish moving a window before the image is taken. Keep the delay explicit so it is easy to adjust:
from datetime import datetime
from pathlib import Path
import time
import pyautogui
out_dir = Path("captures")
out_dir.mkdir(exist_ok=True)
time.sleep(2)
name = datetime.now().strftime("screen-%Y%m%d-%H%M%S.png")
path = out_dir / name
image = pyautogui.screenshot()
image.save(path)
print(f"Saved {path.resolve()} ({image.width}x{image.height})")
The file is relative to the process’s current working directory. Printing path.resolve() removes ambiguity when a scheduler, IDE, or service starts Python from an unexpected directory.
Rank #3
- 1080P HD Webcam: This HD webcam delivers crisp 1080p video quality, ideal for PCs, desktops, and laptops. Perfect for video calls, online classes, meetings, live streaming, gaming, and everyday recording. It provides clear, sharp images and smooth video at up to 30 frames per second. This live streaming webcam works with platforms such as Zoom, Teams, FaceTime, Google Meet, and YouTube.
- USB Plug and Play Webcam: Designed for PCs, this webcam is easy to use. No drivers or software are required; simply connect the webcam to your computer and start using it immediately. Operation is smooth and convenient. XWEIRYN webcams are compatible with multiple operating systems, including Mac/Windows XP/7/8/10/11/PC/Laptops.
- Widely Compatible Webcam: This versatile webcam is compatible with most operating systems and major video platforms. As a reliable computer webcam, it supports video conferencing, remote learning, live streaming, and gaming, meeting your various needs for daily work and entertainment.
- Smooth and Stable Performance: This webcam uses a stable transmission chip to ensure smooth, lag-free video streaming, synchronized audio and video, and no dropped frames. Even after prolonged use, this durable webcam maintains stable performance. It performs excellently even in low-light environments. It automatically adjusts to adapt to low-light conditions, reducing noise and restoring vibrant colors, ensuring clear and sharp images even without additional studio lighting.
- Compact and Adjustable Design: This lightweight and portable webcam saves space and comes with an adjustable clip. Our USB webcam uses a reliable USB 2.0/3.0 connection and comes with an upgraded 1.5-meter (5-foot) braided cable. It is compatible with Desktop most monitors and Laptop. Its portable design makes it easy to place and carry, ideal for home, office, or travel use.
Capture a defined rectangle with a timestamp
from datetime import datetime
from pathlib import Path
import pyautogui
left, top, width, height = 120, 90, 1024, 720
out_dir = Path("captures")
out_dir.mkdir(exist_ok=True)
path = out_dir / datetime.now().strftime("region-%Y%m%d-%H%M%S.png")
image = pyautogui.screenshot(region=(left, top, width, height))
image.save(path)
print(path.resolve())
Use a full-screen capture when context outside the target matters. Use a region when privacy, file size, or downstream processing makes the rest of the desktop irrelevant.
Performance and repeated captures
PyAutoGUI’s screenshot documentation reports roughly 100 milliseconds on a 1920 × 1080 screen. That is guidance for that resolution, not a guarantee for every computer, display arrangement, or operating system. Measure your own complete workflow if timing is important.
For polling or monitoring, capture only the area you need:
import time
import pyautogui
region = (400, 200, 500, 300)
for index in range(10):
image = pyautogui.screenshot(region=region)
image.save(f"captures/check-{index:02d}.png")
time.sleep(1)
Smaller images reduce later comparison and encoding work. If you use PyAutoGUI’s image-location functions after capturing, the documentation says locate calls can take about one or two seconds; supplying a restrictive region can improve search speed. Current documented behavior raises ImageNotFoundException when no match is found, so handle that exception rather than assuming every search succeeds.
import pyautogui
try:
point = pyautogui.locateOnScreen("button.png", region=(0, 0, 900, 700))
except pyautogui.ImageNotFoundException:
point = None
if point is None:
print("Button was not found")
else:
print(f"Found at {point}")
If you maintain code across releases, check the installed PyAutoGUI documentation for the exact exception behavior; older releases may differ.
Rank #4
- 1080P Webcam with Cover for Video Calls - EMEET computer webcam provides design and Optimization for professional video streaming. Realistic 1920 x 1080p video, 5-layer anti-glare lens, providing smooth video. C960 computer camera delivers 1920x1080 video with fixed focus (11.8–118.1 inches), so as to provide a clearer image. C960 USB webcam has a cover and can be removed automatically to meet your needs for privacy. For optimal image performance, use the webcam in a well-lit environment.
- Built-in 2 Omnidirectional Mics - EMEET webcam with microphone for desktop features 2 built-in omnidirectional microphones, picking up your voice to create clear audio for communication. When installing the webcam, select EMEET C960 as the default microphone input device in your computer and video applications and select C960 as the default device in Zoom/Teams and ensure microphone permissions are enabled for proper use. Please note that C960 does not include built-in speakers.
- Automatic Light Adjustment - Automatic exposure adjustment is applied in EMEET HD webcam 1080p so that the streaming webcam can deliver stable image performance. EMEET C960 camera for computer also features color adjustment and exposure optimization to help you look your best. For optimal video quality, it is recommended to use the webcam in normal or well-lit environments and select suitable video settings in your application. Proper lighting helps achieve a clearer and more balanced image.
- Plug-and-Play & Upgraded USB Connectivity - New C960 webcam features both USB Type-A & A-to-C adapter connections for wider compatibility. For stable performance, connect the webcam directly to the computer's main USB port and ensure the device is recognized correctly. If a hub or docking station is used, please ensure it provides sufficient power and stable data transmission, as limited ports may affect performance. 90° wide-angle lens captures more participants without frequent adjustments.
- High Compatibility & Multi Application - C960 webcam for laptop is compatible with Windows 10/11, macOS 10.14+, and Android TV 7.0+. Not supported: Windows Hello, TVs, tablets, or game consoles. It works with Zoom, Teams, Facetime, Google Meet, YouTube and more. Please select C960 webcam as the default camera and microphone device in your application and ensure camera/microphone permissions are enabled, especially on macOS. (Tips: Incompatible with Windows Hello)
Full-screen versus region capture
| Decision | Full display | Region |
|---|---|---|
| Call | pyautogui.screenshot() |
pyautogui.screenshot(region=(left, top, width, height)) |
| Coverage | Everything currently visible in the desktop output. | Only the specified rectangle. |
| Typical use | Bug reports, demonstrations, or preserving surrounding context. | Focused panels, privacy-sensitive areas, and repeated processing. |
| Data volume | Largest image for a given display. | Smaller when the rectangle is smaller. |
PyAutoGUI is a cross-platform interface, while an operating-system-native capture API may offer platform-specific controls. The supplied PyAutoGUI documentation does not establish benchmark results comparing those alternatives, so choose a native API only when you need a capability that this desktop-level call does not provide.
Troubleshoot common failures
ModuleNotFoundError: No module named 'pyautogui'
Install into the interpreter that runs the script:
python3 -m pip install pyautogui
In an IDE, select that same virtual environment as the project interpreter, then rerun the import test.
Pillow-related import or screenshot errors
Screenshot support requires Pillow. Reinstall or upgrade the package in the active environment:
python3 -m pip install --upgrade Pillow pyautogui
Linux reports that a screenshot backend is unavailable
Install scrot and retry:
sudo apt-get install scrot
Also ensure the script runs inside a graphical desktop session with permission to read the display. A command-line-only or inaccessible display session cannot provide the visible desktop that PyAutoGUI captures.
The image is blank or the wrong area
- Confirm that the target window is visible before calling
screenshot(). - Print
image.sizeand verify that your assumed display dimensions match the returned image. - Recheck the tuple order: it is
(left, top, width, height), not right, bottom coordinates. - Move the rectangle temporarily to
(0, 0, 300, 300)to test whether the problem is coordinate selection.
locateOnScreen() raises an image-not-found exception
The reference behavior is to raise ImageNotFoundException when no match exists. Catch it, inspect the saved screenshot, and narrow or adjust the search region. Differences in scale, theme, or the target’s current state can make an image template fail to match.
Recommended Free Tools
Best Value
The output path cannot be opened
Create the parent directory before saving and use an absolute path while diagnosing permissions. The Path(...).parent.mkdir(parents=True, exist_ok=True) pattern in the examples handles missing directories but cannot override operating-system write permissions.
Or skip the browser setup
If your goal is a website image rather than a picture of your own desktop, a screenshot API avoids opening a browser and positioning windows. ScreenshotNeo accepts a URL and returns PNG, JPEG, WebP, or PDF. It removes cookie-consent banners, newsletter popups, and chat widgets before capture; bot checks, blank pages, timeouts, failed loads, and cache hits are not billed, and response headers identify the page verdict and billing status. Its MCP server provides take_screenshot, get_page_info, and capture_pdf tools for Claude, Cursor, and other MCP clients.
For the complete parameter list, see the ScreenshotNeo documentation. A one-call cURL request is:
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
The equivalent Python request is:
import requests
r = requests.get(
"https://api.screenshotneo.com/v1/shot",
params={"access_key": "YOUR_API_KEY", "url": "https://stripe.com"},
timeout=90,
)
r.raise_for_status()
open("shot.webp", "wb").write(r.content)
And Node.js:
const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://stripe.com' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);
if (!res.ok) throw new Error(`HTTP ${res.status}`);
const fs = await import('node:fs/promises');
await fs.writeFile('shot.webp', Buffer.from(await res.arrayBuffer()));
ScreenshotNeo includes full-page capture with lazy images loaded, CSS-selector element capture, custom CSS and JavaScript, waits, request blocking, headers and cookies, device presets, dark mode, PDFs, signed links, asynchronous webhooks, bulk capture, caching, and a usage API. The Free plan includes 1,000 screenshots each month without a card; paid plans start at $5 for 3,000 screenshots. Create a free ScreenshotNeo account to try it.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
FAQ
Does the saved filename determine where the image goes?
Yes. A relative filename is resolved against Python’s current working directory, which may differ between a terminal, IDE, and scheduled job. Print Path(path).resolve() when you need the exact location.
Can this method capture a website without displaying it?
PyAutoGUI is a desktop screenshot tool: it captures what is rendered in the accessible graphical display. For URL-based, repeatable website rendering without arranging a local desktop, use an API such as ScreenshotNeo instead.
Frequently Asked Questions
Does the saved filename determine where the image goes?
Yes. A relative filename is resolved against Python’s current working directory, which may differ between a terminal, IDE, and scheduled job. Print Path(path).resolve() when you need the exact location.
Can this method capture a website without displaying it?
PyAutoGUI captures the accessible graphical desktop. For URL-based rendering without arranging a local desktop, use an API such as ScreenshotNeo.
Do these 3 things before closing this tab:
1Scan for outdated or missing drivers - takes under a minute2Repair Windows errors before they cause bigger problems3Fix the driver behind crashes, sound loss and screen glitchesQuick Recap
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.

