Takes screenshots without pywin32 dependency (whole screen/single window)
Project description
Takes screenshots without pywin32 dependency (whole screen/single window)
pip install ctypes-screenshot
from ctypes_screenshots import screencapture_window, list_windows, screencapture
import cv2
import time
# get the hwnd if you want to capture a single window
list_windows()
# Out[5]:
# [WindowInfo(pid=1544, title='Seagate Expansion Drive (F:)', hwnd=525322, length=29),
# WindowInfo(pid=1840, title='', hwnd=72700, length=1),
# WindowInfo(pid=1840, title='', hwnd=72702, length=1),
# WindowInfo(pid=1840, title='jFDSk.png @ 100% (Layer 1, RGB/8)', hwnd=2362732, length=34),
# WindowInfo(pid=3416, title='', hwnd=131744, length=1),
# captures a single window
for _ in screencapture_window(hwnd=5901160):
last_time = time.time()
cv2.imshow("OpenCV/Numpy normal", _)
if cv2.waitKey(25) & 0xFF == ord("q"):
cv2.destroyAllWindows()
break
print(f"fps: {1 / (time.time() - last_time)}", end="\r")
# uses mss
for _ in screencapture(monitor={"top": 40, "left": 0, "width": 800, "height": 640}):
last_time = time.time()
cv2.imshow("OpenCV/Numpy normal", _)
if cv2.waitKey(25) & 0xFF == ord("q"):
cv2.destroyAllWindows()
break
print(f"fps: {1 / (time.time() - last_time)}", end="\r")
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for ctypes_screenshots-0.12-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | aad6532d2563f005cf693b23f5802dd8b6a1458937a8300cf61574f73162691e |
|
MD5 | dbed88558a6e0a2eee385568273209d5 |
|
BLAKE2b-256 | cce2010205bc25996d9913f8423e0fe852f7cb4fed5970cb093397af0e58e1f9 |