C# 如何获取屏幕上特定点的坐标。 (不是鼠标位置)
我有以下问题: 我正在用 C# 编写一个 WinForms 应用程序,我想获取图片一部分的屏幕坐标,在本例中是手的顶部(由红点标记)。
有谁知道我如何以编程方式做到这一点?
("Koordn dieses Punktes" = 该点的坐标)
编辑: 抱歉让您感到困惑,上面的图片只能说明我的问题。我的程序的实际目标是将飞镖游戏中鼠标控制的手移动到正确的位置,但仅将 MouseLocation 设置为固定点是不可能的,因为飞镖手每次都会获得另一个 x :y 到 MouseLocation 的距离。所以我需要找到飞镖的位置(-箭头)。
我希望每个人都知道我现在的问题是什么。
I have the following problem:
I'm writing a WinForms application with C# and i want to get the Screen - Coordinates of a part of a picture, in this case the top of this hand (marked by the red point).
Does anybody know how i can do this programmaticaly?
("Koordinaten dieses Punktes" = Coordinates of this Point)
EDIT:
sry for confusing you, the picture above should only demonstrate my problem. The actual target of my program is to move the mouse-controlled-hand of a dart game to the right position, but it isn't possible by only setting the MouseLocation to a fix Point, because every turn the dart-hand gets another x:y distance to the MouseLocation. So I need to find the Location of the dart (-arrow).
I hope that everybody knows what my problem is now.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在某些表单使用情况下:
将 Point 替换为您感兴趣的点(相对于表单)。
In some event of the form use:
Replace the Point by the point (relative to the form) you are interested in.
如果窗口最小化、隐藏或离开屏幕,Control.PointToScreen 将无法正常工作。
您必须下拉至 Interop with Win32 API:
因此首先导入 API:
并使用它:
Control.PointToScreen won't work correctly if your window is minimized, hidden or off the screen.
You'll have to drop down to Interop with Win32 APIs:
so start by importing the API:
and use it: