Answers for "python take screenshot of specific window linux"


python screenshot specific window

import pyautogui
import win32gui

def screenshot(window_title=None):
    if window_title:
        hwnd = win32gui.FindWindow(None, window_title)
        if hwnd:
            x, y, x1, y1 = win32gui.GetClientRect(hwnd)
            x, y = win32gui.ClientToScreen(hwnd, (x, y))
            x1, y1 = win32gui.ClientToScreen(hwnd, (x1 - x, y1 - y))
            im = pyautogui.screenshot(region=(x, y, x1, y1))
            return im
            print('Window not found!')
        im = pyautogui.screenshot()
        return im

im = screenshot('Calculator')
if im:
Posted by: Guest on March-24-2021

Code answers related to "python take screenshot of specific window linux"

Python Answers by Framework

Browse Popular Code Answers by Language