Been looking to get started w/ pyobjc in order to simulate some mouse-events/keystrokes equivalent to ctypes on windows. Ran a clean install of pyobjc (pyobjc-core was downloaded first, then pyobjc). Below is the code that I have been trying out (source):
from Quartz.CoreGraphics import CGEventCreateMouseEvent
from Quartz.CoreGraphics import CGEventPost
from Quartz.CoreGraphics import kCGEventMouseMoved
from Quartz.CoreGraphics import kCGEventLeftMouseDown
from Quartz.CoreGraphics import kCGEventLeftMouseDown
from Quartz.CoreGraphics import kCGEventLeftMouseUp
from Quartz.CoreGraphics import kCGMouseButtonLeft
from Quartz.CoreGraphics import kCGHIDEventTap
def mouseEvent(type, posx, posy):
theEvent = CGEventCreateMouseEvent(
None,
type,
(posx,posy),
kCGMouseButtonLeft)
CGEventPost(kCGHIDEventTap, theEvent)
def mousemove(posx,posy):
mouseEvent(kCGEventMouseMoved, 845, 396);
def mouseclick(posx,posy):
mouseEvent(kCGEventMouseMoved, 845, 396);
mouseEvent(kCGEventLeftMouseDown, 845, 396);
mouseEvent(kCGEventLeftMouseUp, 845, 396);
Which yields the following error as most recent:
File "/usr/local/lib/python3.5/site-packages/objc/__init__.py", line 15, in _update
import objc._objc as _objc
ImportError: dlopen(/usr/local/lib/python3.5/site-packages/objc/_objc.cpython-35m-darwin.so, 2): Symbol not found: _PyObject_REPR
Referenced from: /usr/local/lib/python3.5/site-packages/objc/_objc.cpython-35m-darwin.so
Expected in: flat namespace
in /usr/local/lib/python3.5/site-packages/objc/_objc.cpython-35m-darwin.so
Clearly the issue is that _PyObject_REPR is absent from Python3.5, and so the init script fails. Having gone on the bitbucket 'issues' page, I found this. One of the users (Kentzo) amended the pyobjc github to remove the involvement of _PyObject_REPR.
My question: how do I go about correctly installing his amended version? I have attempted the standard 'pip3 install "link"' method, however I cannot seem to install it over my existing pyobjc files. Do I need to manually remove all of the pyobjc files via sudo?
As you can probably tell I'm a bit of a noob, so any guidance would be much appreciated!
Thanks!