[Pyobjc-dev] PyObjC CGPoint error in CGEventCreateMouseEvent
Brought to you by:
ronaldoussoren
From: Pepijn de V. <pep...@gm...> - 2010-04-04 15:27:50
|
Hi all, I finally managed to get listening to events working, the code is at http://github.com/pepijndevos/PyMouse/blob/master/mac.py#L30 I don't know what made the difference, but after a lot of trying it suddenly worked. Now I have another strange issue. When I run the default Python and PyObjC version that came with Mac OS X 10.6, Python segfaults while creating an event tap. When I run Python26 and PyObjC from Macports the event system works fine, but making an event breaks the location. Stock Python: >>> from Quartz import * >>> def test(*args): ... print args ... >>> tap = CGEventTapCreate( ... kCGSessionEventTap, ... kCGHeadInsertEventTap, ... kCGEventTapOptionDefault, ... CGEventMaskBit(kCGEventMouseMoved) | ... CGEventMaskBit(kCGEventLeftMouseDown) | ... CGEventMaskBit(kCGEventLeftMouseUp) | ... CGEventMaskBit(kCGEventRightMouseDown) | ... CGEventMaskBit(kCGEventRightMouseUp) | ... CGEventMaskBit(kCGEventOtherMouseDown) | ... CGEventMaskBit(kCGEventOtherMouseUp), ... test) Segmentation fault Macports Python: >>> from Quartz import * >>> event = CGEventCreateMouseEvent(None, 3, CGPoint(200, 200), 1) >>> CGEventGetLocation(event) <NSPoint x=13510801139695616.0 y=6.953222975623699e-310> Also the stock version of CGEventTapCreate needs 5 parameters while the Macports version needs 6. Macports version of PyObjC is 2.2 Included version should be 2.2b3 according to a blog I found. Groeten, Pepijn de Vos -- Sent from my iPod Shuffle http://pepijndevos.nl |