Wednesday, February 6, 2013

How To: Obj-C Set Mouse Position

Reference: http://stackoverflow.com/questions/8059667/set-the-mouse-location

Code:
 CGEventSourceRef source = CGEventSourceCreate(kCGEventSourceStateCombinedSessionState);
  CGEventRef mouse = CGEventCreateMouseEvent (NULL, kCGEventMouseMoved, CGPointMake( X, Y), 0);
  CGEventPost(kCGHIDEventTap, mouse);
  CFRelease(mouse);
  CFRelease(source);
Include:
 #include <ApplicationServices/ApplicationServices.h>

You just set the X and Y.

No comments:

Post a Comment