Image Grab PIL (Swwan)
Screenshot your desktop straight into a workflow
- image
This node has one job and it's a strange one: it captures a rectangle of your actual screen and hands it to ComfyUI as an IMAGE. Its category is Swwan/Experimental, and the pack's own description gives the intended use away - "Can be used for realtime diffusion with autoqueue."
That's the pitch. Point it at a region of your display, queue the prompt, and the same region of your screen keeps being fed through whatever you've wired up. Live stylisation of a browser window, a video player, a paint program, a game. It's the low-tech, zero-latency-cost version of a webcam or a capture card.
Inputs and output
x, y, width, height - all INT, all clamped 0–4096, with width and height defaulting to 512. They define the capture rectangle as (x, y, x+width, y+height) in screen coordinates, with the origin at the top-left of your primary display.
num_frames (INT, default 1, 1–255) and delay (FLOAT, default 0.1, 0–10, step 0.01) turn it into a burst: if num_frames is greater than one, the node grabs a frame, sleeps delay seconds, grabs again, and repeats. Output is a batch of that many frames, ready for Video Combine or an interpolator.
One output: image.
The node prints how long the grab took, which is more useful than it sounds - if the capture is eating 200ms per frame, that's your realtime ceiling, not the sampler.
The part that decides whether this works at all
ImageGrab is Pillow's screenshot back end, and it is platform-shaped in ways that will ruin your evening if you find out late:
- Windows is the happy path. Full-desktop and region grabs just work.
- macOS works but requires Screen Recording permission for whichever process launched ComfyUI (Terminal, or your Python host, depending on how you start it). Before you grant it, grabs come back as a desktop wallpaper with no windows on it - the classic symptom, and it looks exactly like a bug in the node.
- Linux/X11 goes through Pillow's X support. Wayland is where it gets ugly: screen capture under Wayland is compositor-mediated, Pillow's grab path generally doesn't get what it wants, and the usual answer is a portal-based tool like
grim/slurpfor wlroots or a GNOME-specific helper. If you're on Wayland and get black or wrong-region captures, that's the cause, not your install.
If you're running ComfyUI on a headless box - a server, a Docker container, a rented GPU - there is no display to grab. This node will error or hand you nothing useful. It captures the machine ComfyUI is running on, not the machine your browser is on. That's the single most common misunderstanding with this class of node.
Making it loop
For realtime use you want ComfyUI to keep re-running without you clicking. That's the autoqueue toggle in the UI - turn it on, let the queue drain and refill itself. The node also overrides ComfyUI's change detection, which is the pack's way of saying the capture is expected to be different every run; if you don't want it re-running, turn autoqueue off rather than relying on caching.
A practical note: realtime diffusion chains are latency chains, and a screenshot grab plus a full sampler will be far slower than the capture. The node is the cheap part. Size your capture region down before you start tuning anything else.
Install
cd /path/to/ComfyUI/custom_nodes
git clone https://github.com/aining2022/ComfyUI_Swwan.git
cd ComfyUI_Swwan
python -m pip install -r requirements.txt
Windows portable:
.\python_embeded\python.exe -m pip install .\ComfyUI\custom_nodes\ComfyUI_Swwan\requirements.txt
Restart ComfyUI, hard-refresh the browser, search Swwan; it's under Swwan/Experimental along with the pack's other device-facing odds and ends. There's no model download and no extra dependency beyond the Pillow you already have - the whole node is about fifteen lines around ImageGrab.grab.
It is a niche node with almost no community footprint, so don't expect much in the way of troubleshooting threads. The permission and display-backend issues above are the entire failure surface, and if the capture is black or empty, your questions are about your OS, not about ComfyUI.
Inputs (6)
| Name | Type | Default | Description |
|---|---|---|---|
| x | INT | 00–4096 | — |
| y | INT | 00–4096 | — |
| width | INT | 5120–4096 | — |
| height | INT | 5120–4096 | — |
| num_frames | INT | 11–255 | — |
| delay | FLOAT | 0.100–10 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| image | IMAGE | — |