鼠标坐标

发布于 2024-09-12 00:21:08 字数 23 浏览 0 评论 0原文

Mac下C语言如何获取鼠标坐标?

How can i get mouse coordinates in C under Mac?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

蓝颜夕 2024-09-19 00:21:08

我不知道任何完全纯 C 的实现,但在 OSX(10.5+)的基础框架中,有一个名为“HIGetMousePosition”的函数。您应该能够将其与您的 C 程序集成。

http://allancraig.net/index.php?option=com_content&view=article&id=137:getting-mouse-coordinates&catid=39:objective-c&Itemid=86 显示本实施例:

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;
}

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;
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文