I need to set the position of the mouse on the screen. In some other similar question, it was suggested to use CGDisplayMoveCursorToPoint(CGDirectDisplayID display, CG
Here's a way to do it:
// coordinate at (10,10) on the screen
CGPoint pt;
pt.x = 10;
pt.y = 10;
CGEventRef moveEvent = CGEventCreateMouseEvent(
NULL, // NULL to create a new event
kCGEventMouseMoved, // what type of event (move)
pt, // screen coordinate for the event
kCGMouseButtonLeft // irrelevant for a move event
);
// post the event and cleanup
CGEventPost(kCGSessionEventTap, moveEvent);
CFRelease(moveEvent);
This will move the cursor to point (10,10) on screen (the upper left, next to the Apple menu).