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.4.tar.gz (4.0 kB view details)

Uploaded Source

Built Distribution

bshot-1.0.4-py3-none-any.whl (5.1 kB view details)

Uploaded Python 3

File details

Details for the file bshot-1.0.4.tar.gz.

File metadata

  • Download URL: bshot-1.0.4.tar.gz
  • Upload date:
  • Size: 4.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.18

File hashes

Hashes for bshot-1.0.4.tar.gz
Algorithm Hash digest
SHA256 604765fe0c33ae85b3c8013a5828f49a653c92c7fbc04487ea773a55ce53c229
MD5 46fc217ffade989ee115a78fc3958320
BLAKE2b-256 13db7e13725acb0c82bbfdb34609842577399caaac2102111e7a86e98114ca3d

See more details on using hashes here.

File details

Details for the file bshot-1.0.4-py3-none-any.whl.

File metadata

  • Download URL: bshot-1.0.4-py3-none-any.whl
  • Upload date:
  • Size: 5.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.18

File hashes

Hashes for bshot-1.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 ee6e302de2cb1cf8b3e5c54717577dac7abb3db10f69b6df7a26142bafef5061
MD5 e886dccc60b5667232e6a5f685d13d72
BLAKE2b-256 ea366386b26f382ec6dbf395a154852d2dc31c24100049d729f3807cc20d2bc6

See more details on using hashes here.

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