Key Events Handling using PyObjC in Mac OS X

此生再无相见时 提交于 2019-12-11 03:29:59

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!