Answers for "how to print screen on specific window python"

0

python screen capture a window

from win32gui import FindWindow, GetWindowRect
from PIL import ImageGrab
from PIL import Image
import numpy as np
import cv2

while True:
    window_handle = FindWindow(None, "MTGA")
    window_rect = GetWindowRect(window_handle)
    screen = np.array(ImageGrab.grab(bbox=(window_rect)))
    resized = cv2.resize(screen, (1280, 720), interpolation = cv2.INTER_AREA)
    im_rgb = cv2.cvtColor(resized, cv2.COLOR_BGR2RGB)
    cv2.imshow('Python Window', im_rgb)
    if cv2.waitKey(25) & 0xFF == ord('q'):
        cv2.destroyAllWindows()
        break
Posted by: Guest on April-28-2021
0

how to make a screen in python

import pygame
pygame.init()

sh = int(500)
sw = int(500)
win = pygame.display.set_mode((sh, sw))

run = True
while run:
    pygame.time.delay(100)
	for event in pygame.event.get():
        if event.type == pygame.QUIT:
            run = False
Posted by: Guest on May-08-2020

Code answers related to "how to print screen on specific window python"

Python Answers by Framework

Browse Popular Code Answers by Language