Skip to content

Instantly share code, notes, and snippets.

@RakeshChouhan
Created December 19, 2019 11:31
Show Gist options
  • Save RakeshChouhan/94a12836f1b7124b763f269fa81230d3 to your computer and use it in GitHub Desktop.
Save RakeshChouhan/94a12836f1b7124b763f269fa81230d3 to your computer and use it in GitHub Desktop.
Takes screenshot from your system
import pyautogui
import tkinter as tk
from tkinter import filedialog
import keyboard
root= tk.Tk()
canvas1 = tk.Canvas(root, width = 300, height = 300)
canvas1.pack()
def takeScreenshot ():
myScreenshot = pyautogui.screenshot()
file_path = filedialog.asksaveasfilename(defaultextension='.png')
myScreenshot.save(file_path)
myButton = tk.Button(text='Take Screenshot', command=takeScreenshot, bg='green',fg='white',font= 10)
canvas1.create_window(150, 150, window=myButton)
#hot key registered for this.
keyboard.add_hotkey('ctrl+shift+k',takeScreenshot)
root.mainloop()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment