screenshot taker python code example

Example 1: python take screenshot

#pip3 install PrtSc
import PrtSc.PrtSc as Screen
screenshot=PrtSc.PrtSc(True,'filename.png')

Example 2: screenshot taker python

from tkinter.filedialog import *
import pyautogui
import tkinter

root = Tk()
root.title('Take A Screenshot')
root.geometry('300x300')

canvas = tkinter.Canvas(root, width=300, height=300)
canvas.pack()


def takeScreenshot():
    img = pyautogui.screenshot()
    savePath = asksaveasfilename()
    if not ('.png' in savePath): savePath = savePath + '.png'
    img.save(savePath)

button = tkinter.Button(text="Take a Screenschot", command=takeScreenshot, font=10)
canvas.create_window(150, 150, window=button)

root.mainloop()

Tags:

Misc Example