-
Notifications
You must be signed in to change notification settings - Fork 39
Mac new
pepijndevos edited this page Sep 13, 2010
·
1 revision
I just found a way to avoid the deprecated methods.
It’s actually quite easy.
You import all of Quarts, you may do this however you like, change your code accordingly:
from Quartz import *
Then there is this basic sequence you use over and over:
event = CGEventCreateMouseEvent(None, type, (x, y), button)
CGEventPost(kCGHIDEventTap, event)
Button is zero-based, but the way buttons are numbered across systems is inconsistent anyway.
The good thing is that button is ignored most of the time(except with kCGEventOtherMouseDown/Up)
The bad thing is that you need to use those types for events.
These are the ones you care about for mouse stuff:
- kCGEventLeftMouseDown
- kCGEventRightMouseDown
- kCGEventOtherMouseDown
- kCGEventLeftMouseUp
- kCGEventRightMouseUp
- kCGEventOtherMouseUp
- kCGEventMouseMoved