Skip to main content

Python package to take screenshots of windows that are in background

Project description

bshot

Python package to take screenshots of windows that are in background

Installation

pip install bshot

Usage

import cv2
import win32gui

from bshot.screenshot import get_image

hwnd = win32gui.FindWindow(None, "Untitled - Notepad")
img = get_image(hwnd, method="srccopy") # windll and srccopy methods
cv2.namedWindow("bshot", cv2.WINDOW_NORMAL)
cv2.imshow("bshot", img)
cv2.waitKey(0)

Benchmark

The speed of the capture depends on the size of the window that is being captured. It can caputre 220x160 window with 2400+ fps.

import time

import win32gui

from bshot.screenshot import get_image

hwnd = win32gui.FindWindow(None, "Untitled - Notepad")

start = time.time()
count = 0
while time.time() - start < 1:
    get_image(hwnd, method="srccopy")
    count += 1
print("fps =", count)

Limitations

  • The screenshot module uses GetClientRect which can crop some portion of the window contents.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

bshot-1.0.3.tar.gz (3.8 kB view hashes)

Uploaded Source

Built Distribution

bshot-1.0.3-py3-none-any.whl (4.0 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page