问题
I am stuck in a problem.
I am programming screenshot capturing concept using PyObjC.
os.system("screencapture -s %s" % check_snapshot)
This is what I have used to take the screenshot. Here, check_snapshot is a variable storing file location.
screencapture is a built-in function and works perfectly fine.
Now, what I am looking for is, in Mac OS X, whenever we press Command + Shift + 3, the whole current window screenshot would be taken, and Command + Shift + 4 will allow you to select a particular area to be captured.
I am looking for the same functionality in my code as well. Whenever Command+Shift+3 is pressed in my code,
os.system("screencapture %s" % check_snapshot)
should be called, and whenever Command+Shift+4 is called,
os.system("screencapture -s %s" % check_snapshot)
should be called.
I have tried many ways out, taken help of Stackoverflow, google and other various forums, but it ain't working in the way I am looking for.
These key event handling and listening and combinations I am looking to implement in PyObjC.
Any help would be appreciated.
Thanks.
来源:https://stackoverflow.com/questions/19630819/key-events-handling-using-pyobjc-in-mac-os-x