CGDisplayMoveCursorToPoint()
only moves the image of the cursor, it does not generate any events. You should create and post mouse events of type kCGEventMouseMoved
to simulate moving the mouse. Your own method would do it:
[self postMouseEventWithButton:0 withType:kCGEventMouseMoved andPoint:point];
For clicks, you are already doing it the right way, I think. One thing you should also do is set the click count properly on both the mouse down and mouse up events, like so:
CGEventSetIntegerValueField(event, kCGMouseEventClickState, 1);
... because some applications need it.
If your code doesn't work, I'm not sure why; it looks OK to me. Try posting to kCGSessionEventTap
instead of kCGHIDEventTap
and see if it helps. Also, you don't need the CGEventSetType()
call since the type is already set in the creation call.
invariant
2010-03-10 21:34:30