Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

python take a screenshot

import pyautogui

myScreenshot = pyautogui.screenshot()
myScreenshot.save(r'Path to save screenshotfile name.png')
Comment

How to take a screenshot using python

import pyautogui
screenshot = pyautogui.screenshot()
screenshot.save("FilePathwhereyouwantToSaveFileName.FileFormat")
Comment

python create and show screenshot

import numpy as np
import pyautogui
import scipy.ndimage
import pygame


class Viewer:
    def __init__(self, display_size):
        pygame.init()
        self.display = pygame.display.set_mode(display_size)
        self.pic = np.zeros((*display_size, 3), dtype=np.uint8)

    def set_title(self, title):
        pygame.display.set_caption(title)

    def set_image(self, image):
        self.pic = image

    def start(self):
        running = True
        while running:
            for event in pygame.event.get():
                if event.type == pygame.QUIT:
                    running = False

            surf = pygame.surfarray.make_surface(self.pic)
            self.display.blit(surf, (0, 0))

            pygame.display.update()

        pygame.quit()


viewer = Viewer((700, 700))

screen_size = pyautogui.size()

img = pyautogui.screenshot()
img = np.array(img)
img = np.rot90(img)
img = np.flipud(img)
background = np.zeros((700, 700, 3), dtype=np.uint8)
img = scipy.ndimage.zoom(img, (min(700 / img.shape[0], 700 / img.shape[1]),
                               min(700 / img.shape[0], 700 / img.shape[1]), 1))
# blend the image with the background
background[int(350 - img.shape[0] / 2):int(350 + img.shape[0] / 2),
           int(350 - img.shape[1] / 2):int(350 + img.shape[1] / 2), :] = img
viewer.set_image(background)
viewer.start()
Comment

how to take screenshot with python


import pyautogui
im2 = pyautogui.screenshot('my_screenshot.png', region=(x,y, width, height))
Comment

PREVIOUS NEXT
Code Example
Python :: flask clear session 
Python :: convert number to time python 
Python :: python split tuples into lists 
Python :: create spark dataframe in python 
Python :: python delete the last line of console 
Python :: django get user model funciton 
Python :: how to get the code of a website in python 
Python :: subtract one list from another python 
Python :: convert series to datetime 
Python :: np replace nan 
Python :: pyqt expressions 
Python :: python system of equations 
Python :: python rickroll code 
Python :: check pip installed packages inside virtualenv 
Python :: how to take second largest value in pandas 
Python :: with python how to check alomost similar words 
Python :: numpy apply log to array 
Python :: pandas replace nan 
Python :: how to auto update chromedriver selenium python 
Python :: how to make a crosshair in python 
Python :: build url python 
Python :: python tkinter go to another window on button click 
Python :: scipy correlation 
Python :: tkinter entry read only 
Python :: python check version 
Python :: text to pandas 
Python :: remove n string 
Python :: first day of the month python 
Python :: install python3 6 ubuntu 20 
Python :: python datetime date only 
ADD CONTENT
Topic
Content
Source link
Name
9+1 =