Problem with PyObjC and NSEvents

K

kle

Hello all,

I am having a rather specialized problem involving PyObjC and receiving NSEvents, and I'm wondering whether anybody here might have any insight.

I'm writing a Python program, using PyObjC, that runs in the background andregisters whenever the user clicks the mouse, in any application.

I do this using an NSEvents global events monitor:

NSEvent.addGlobalMonitorForEventsMatchingMask_handler_(NSLeftMouseDownMask,handler)

where "handler" is the name of my handler method.

The code works fine when I run the .py file from the command line -- my handler method is called whenever I click the mouse, and everything happens asexpected.

However, when I bundle it into a standalone app (using py2app) and run it, the app fails to register clicks. I have gotten it to work intermittently -- sometimes it will start working after the app has been brought to the front for the first time. But for the most part, it doesn't register the clicks at all.

Any ideas on what I might try to get it working? I am not sure whether thisis an NSEvents problem or a PyObjC problem, or just a me being stupid problem. But any help or guidance would be greatly appreciated.

Thanks,

Emily
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,767
Messages
2,569,570
Members
45,045
Latest member
DRCM

Latest Threads

Top