I've been using CGPostMouseEvent() for performing mouse clicks since mac os 10.4.
While working on my code and trying to make it 100% compatible with Snow Leopard, XCode spit a warning saying that CGPostMouseEvent() is deprecated. While this doesn't scare me, I'd like to know what replaces CGPostMouseEvent(). This is how I use it:
CGPostMouseEvent(point,FALSE,1,TRUE); // mouse down
CGPostMouseEvent(point,FALSE,1,FALSE); // mouse up
That's all.
Any ideas?
Thanks!
CGEventCreateMouseEvent
can be used with CGEventPost
in a non-deprecated fashion. The reference is here.
Edit from OP:
Something like this?
void PostMouseEvent(CGMouseButton button, CGEventType type, const CGPoint point)
{
CGEventRef theEvent = CGEventCreateMouseEvent(NULL, type, point, button);
CGEventSetType(theEvent, type);
CGEventPost(kCGHIDEventTap, theEvent);
CFRelease(theEvent);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With