如何存储(和使用)当前鼠标位置? [英] How to store (and use) the current mouse position?

查看:188
本文介绍了如何存储(和使用)当前鼠标位置?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

存储当前鼠标位置(系统范围),然后(稍后)将鼠标放在该存储点上的最佳方法是什么?

What is the best way to store the current mouse position (system-wide) and then (later) put the mouse at that stored point?

[NSEvent mouseLocation] 得到我的位置,我可以移动鼠标与 CGEventMouseMoved ,但他们每个使用不同的坐标系统(我相信y = 0是NSEvent的顶部,底部是CGEvent)。

[NSEvent mouseLocation] gets me the position, and I can move the mouse with a CGEventMouseMoved, but they each use a different co-ordinates system (I believe y=0 is the top for NSEvent and the bottom for a CGEvent).

我担心捕获屏幕高度的鲁棒性,并使用它在两者之间进行转换 - 或者这是最好的方法吗?

I'm worried about the robustness of capturing the screen height and using it to convert between the two - or is this the best approach?

推荐答案

是的,使用主屏幕的高度是翻转屏幕坐标的标准方式。

Yes, using the main screen's height is the standard way of flipping screen coordinates.

这篇关于如何存储(和使用)当前鼠标位置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆