1please check out my video also - https://www.youtube.com/watch?v=7Tr0mEQhc3M&t=2s
2please subscribe my channel - https://bit.ly/2Me2CfB
3
4# importing the ImageGrab function from PILLOW (PIL) Module
5from PIL import ImageGrab
6
7# to take the screenshot of your pc (Main Function)
8screenshot = ImageGrab.grab()
9
10# saving the screenshot in your pc (screenshot will be saved in the directory you are working)
11screenshot.save()
12
13# To open the screenshot in the default image viewer (Optional)
14screenshot.show()
1import pyautogui
2import tkinter as tk
3import time
4root= tk.Tk()
5
6canvas1 = tk.Canvas(root, width = 300, height = 300)
7
8canvas1.pack()
9
10def takeScreenshot ():
11 current_time = time.time()
12 myScreenshot = pyautogui.screenshot()
13 myScreenshot.save(r'D:\videos\Mannuly\Taken'+str(current_time)+".png")
14
15myButton = tk.Button(text='Take Screenshot', command=takeScreenshot, bg='green',fg='white',font= 10)
16canvas1.create_window(150, 150, window=myButton)
17
18root.mainloop()