Skip to content

Instantly share code, notes, and snippets.

@stek29
Created May 31, 2018 05:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stek29/0f0703a350deb996d517051fd50c881f to your computer and use it in GitHub Desktop.
Save stek29/0f0703a350deb996d517051fd50c881f to your computer and use it in GitHub Desktop.
// File:
// click.m
//
// stek29 2015
//
// Compile with:
// cc -o click click.m -framework ApplicationServices -framework Foundation
//
// Usage:
// ./click x_cord y_cord
// At the given coordinates it will click and release.
//
// See http://hints.macworld.com/article.php?story=2008051406323031
#import <Foundation/Foundation.h>
#import <ApplicationServices/ApplicationServices.h>
int main(int argc, char *argv[]) {
@autoreleasepool {
// NSArgumentDomain
NSUserDefaults *args = [NSUserDefaults standardUserDefaults];
int x = [args integerForKey:@"x"];
int y = [args integerForKey:@"y"];
CGPoint pt;
pt.x = x;
pt.y = y;
CGPostMouseEvent( pt, 1, 1, 1 );
CGPostMouseEvent( pt, 1, 1, 0 );
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment