In 2010, Pierre asked this question (his accepted answer does not work for me).
I have the same problem: I can successfully move the mouse (and turn off!?!) On the screen programmatically from my Cocoa application, however moving the mouse to the location of my dock does not show it (and some other applications do not register the mouse move event, for example, games that remove the mouse)
Method used:
void PostMouseEvent(CGMouseButton button, CGEventType type, const CGPoint point) { CGEventRef theEvent = CGEventCreateMouseEvent(NULL, type, point, button); CGEventSetType(theEvent, type); CGEventPost(kCGSessionEventTap, theEvent); CFRelease(theEvent); }
And then when I want to move the mouse, I run:
PostMouseEvent(0, kCGEventMouseMoved, mouseLocation);
Note that this code generates mouseover events for things like links.
Now that in 2013, is it possible to fix this problem?
Thank you for your time!
source share