How can i ge开发者_Go百科t mouse coordinates in C under Mac?
I'm not avare of any fully only C implementation, but in the foundation framework of OSX (10.5+) there is a function called "HIGetMousePosition". You should be able to integrate this with your C program.
http://allancraig.net/index.php?option=com_content&view=article&id=137:getting-mouse-coordinates&catid=39:objective-c&Itemid=86 shows this example implementation:
int main (int argc, const char * argv[])
{
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
HIPoint point;
HICoordinateSpace space = 2;
HIGetMousePosition(space, NULL, &point);
printf("%.2f %.2f", point.x, point.y);
[pool drain];
return 0;
}
精彩评论