I am writing a Mac OS X application on Snow Leopard. I have a steps method that runs at regular intervals using NSTimer. In this method, I would like to move the mouse to the center of the screen, without pressing or releasing the buttons. Here is what I have:
-(void) step: (NSTimer *) timer { NSRect bounds = [self bounds]; CGPoint point = CGPointMake(bounds.origin.x + bounds.size.width / 2.0f, bounds.origin.y + bounds.size.height / 2.0f); CGEventCreateMouseEvent(NULL, kCGEventLeftMouseDragged, point, 0); }
It does nothing. Can someone tell me what's wrong?
source share