Created
February 9, 2010 04:56
-
-
Save dsturnbull/298926 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import <Foundation/Foundation.h> | |
#import <ApplicationServices/ApplicationServices.h> | |
void move_mouse(const CGPoint pt); | |
int main(int argc, char *argv[]) { | |
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; | |
NSUserDefaults *args = [NSUserDefaults standardUserDefaults]; | |
int x = [args integerForKey:@"x"]; | |
int y = [args integerForKey:@"y"]; | |
CGPoint pt; | |
pt.x = x; | |
pt.y = y; | |
move_mouse(pt); | |
pt.x += 10; | |
move_mouse(pt); | |
[pool release]; | |
return 0; | |
} | |
void move_mouse(const CGPoint pt) { | |
CGEventRef theEvent = CGEventCreateMouseEvent(NULL, kCGEventMouseMoved, pt, kCGMouseButtonLeft); | |
CGEventSetType(theEvent, kCGEventMouseMoved); | |
CGEventPost(kCGHIDEventTap, theEvent); | |
CFRelease(theEvent); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment