Search code examples
pythonwindowsworkflowscreenshot

I would like to speed up my workflow by implementing this little adjustment


My work consists of many activities and one of them is for example taking screenshots, then opening the painting software (Microsoft Paint) and importing the screenshoot into the MS Paint with ctrl+v and afterwards saving the file and ultimately naming (and sometimes selecting the destination, where the file will be saved) the new screenshot. I am taking a lot of screenshots, especially when I am watching educational videos, so I was thinking about some script, (ideally with python) which could change the functionality of the printscreen key on the keyboard, so it would take me to the naming phase automatically. Could anybody please give me any hint? Thank You very much and have a nice day.


Solution

  • import pyautogui
    import tkinter as tk
    import subprocess, os
    
    root= tk.Tk()
    
    canvas1 = tk.Canvas(root, width = 200, height = 90)
    canvas1.pack()
    
    paintPath = os.path.splitdrive(os.path.expanduser("~"))[0]+r"\WINDOWS\system32\mspaint.exe"
    paintImage = r'C:\\Users\\lenovo\\Desktop\\ML\\screenshot.png'
    def takeScreenshot ():
        myScreenshot = pyautogui.screenshot()
        myScreenshot.save(paintImage)
    
    def paintOpen():
        subprocess.Popen([paintPath, paintImage])
    
    screen_s = tk.Button(text='Take Screenshot', command=takeScreenshot, bg='green',fg='white',font= 10)
    canvas1.create_window(100, 30, window=screen_s)
    open_p = tk.Button(text='Open Paint', command=paintOpen, bg='red',fg='white',font= 10)
    canvas1.create_window(100, 70, window=open_p)
    
    root.wm_attributes("-topmost", 1)
    root.mainloop()