如何将Windows屏幕坐标转换为屏幕截图像​​素坐标?

发布于 2024-10-24 12:08:50 字数 49 浏览 2 评论 0原文

我需要在屏幕截图上找到一个控件。我有它的屏幕坐标。如何将它们转换为屏幕截图上的坐标?

I need to find a control on screenshot. I have its screen coordinates. How can I convert them to coordinates on screenshot?

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

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

发布评论

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

评论(1

明月夜 2024-10-31 12:08:50

这完全取决于屏幕截图的大小和当前分辨率的大小。

假设屏幕截图为 800x600,但您当前的屏幕分辨率为 1280x720。为了找出 800x600 图像上的 X,Y 位置,您需要标准化 1280x720 屏幕上的 X,Y 值。

normalized_x = (x * 800) / 1280;
normalized_y = (y * 600) / 720;

请注意,您要查找的对象在 800x600 图像上也较小。所以:

// w and h represents the size of the object at 1280x720
normalized_w = (w * 800) / 1280; 
normalized_h = (h * 600) / 720;

It all depends on the size of the screenshot and the size of your current resolution.

Let's say the screenshot is 800x600, but your current screen resolution is 1280x720. In order to find out the X,Y position on a 800x600 image, you need to normalize the values you have of X,Y on a 1280x720 screen.

normalized_x = (x * 800) / 1280;
normalized_y = (y * 600) / 720;

Note that the object you are looking for is also smaller on a 800x600 image. So:

// w and h represents the size of the object at 1280x720
normalized_w = (w * 800) / 1280; 
normalized_h = (h * 600) / 720;
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文