PHP 8.2.30
Preview: screenshot.py Size: 589 B
/proc/thread-self/root/opt/cloudlinux/venv/lib/python3.11/site-packages/pyvirtualdisplay/examples/screenshot.py

"Create screenshot of xmessage in background using 'smartdisplay' submodule"
from easyprocess import EasyProcess

from pyvirtualdisplay.smartdisplay import SmartDisplay

# 'SmartDisplay' instead of 'Display'
# It has 'waitgrab()' method.
# It has more dependencies than Display.
with SmartDisplay() as disp:
    with EasyProcess(["xmessage", "hello"]):
        # wait until something is displayed on the virtual display (polling method)
        # and then take a fullscreen screenshot
        # and then crop it. Background is black.
        img = disp.waitgrab()
img.save("xmessage.png")

Directory Contents

Dirs: 1 × Files: 7

Name Size Perms Modified Actions
- drwxr-xr-x 2026-02-06 08:01:08
Edit Download
245 B lrw-r--r-- 2026-01-20 13:01:47
Edit Download
266 B lrw-r--r-- 2026-01-20 13:01:47
Edit Download
736 B lrw-r--r-- 2026-01-20 13:01:47
Edit Download
589 B lrw-r--r-- 2026-01-20 13:01:47
Edit Download
772 B lrw-r--r-- 2026-01-20 13:01:47
Edit Download
284 B lrw-r--r-- 2026-01-20 13:01:47
Edit Download
0 B lrw-r--r-- 2026-01-20 13:01:47
Edit Download

If ZipArchive is unavailable, a .tar will be created (no compression).