-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMyNSEvent.m
More file actions
executable file
·38 lines (27 loc) · 820 Bytes
/
MyNSEvent.m
File metadata and controls
executable file
·38 lines (27 loc) · 820 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
//
// MyNSEvent.m
// ScreenCapture
//
// Created by Christian Sonntag on 20.11.10.
// Copyright 2010 __MyCompanyName__. All rights reserved.
//
#import "MyNSEvent.h"
#import <Foundation/Foundation.h>
#import <ApplicationServices/ApplicationServices.h>
#import "MyNSEvent.h"
@implementation MyNSEvent
+(int) clickAtLocation: (NSPoint) pt {
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
int x = pt.x;
int y = pt.y;
CGPoint ptCG;
ptCG.x = x;
ptCG.y = y;
CGEventRef mouseDownEv = CGEventCreateMouseEvent(NULL,kCGEventLeftMouseDown,ptCG,kCGMouseButtonLeft);
CGEventPost (kCGHIDEventTap, mouseDownEv);
CGEventRef mouseUpEv = CGEventCreateMouseEvent(NULL,kCGEventLeftMouseUp,ptCG,kCGMouseButtonLeft);
CGEventPost (kCGHIDEventTap, mouseUpEv );
[pool release];
return 0;
}
@end