take screenshot with python code example
Example 1: screenshot in python
import pyautogui
class gng() :
myScreenshot = pyautogui.screenshot()
myScreenshot.save('C:\File\Code\save.png')
gng()
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()
Example 3: python take screenshot
import PrtSc.PrtSc as Screen
screenshot=PrtSc.PrtSc(True,'filename.png')