Search code examples
pythonscreenshot

Is there a way to call the windows screenshot snipping tool (win+shift+s) in python?


I'm wondering if there's a way to active the windows screenshot snipping tool from a python program. Currently I'm using pynput to press the windows + shift + s key but I feel that there is a better way to perform this.

I've tried to use subprocess to call snipping tool.

subprocess.call([r'C:\\Windows\System32\SnippingTool.exe'])

It opens the actual application but it's not the same as the windows+shift+s one.


Solution

  • SnippingTool.exe provides some command line options to control its behavior. See How to open the SnippingTool (Win Tool) passing a parameter to start automatically?

    To start taking a screenshot (as winshifts does), pass /clip as an argument to it like this.

    subprocess.call([r'C:\\Windows\System32\SnippingTool.exe', '/clip'])