如何在 C# 中将鼠标光标位置设置为屏幕上的指定点? [英] How to Set mouse cursor position to a specified point on screen in C#?
本文介绍了如何在 C# 中将鼠标光标位置设置为屏幕上的指定点?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在C#中将鼠标光标位置设置到屏幕上的指定点?
How to Set mouse cursor position to a specified point on screen in C#?
我必须破解接收鼠标和键盘坐标并按下的主板缓冲区吗???
am i must hacke the motherboard buffer that receive the mouse and keyboard coordinates and presses ???
还有其他人可以点击吗?或者我想象一下???
is there another one to do clicks or i am imagine ???
推荐答案
在 Windows 10 中获取和设置鼠标位置:
在 c# .NET Framework 4.0 中使用 Cursor.Position 属性更简单
Much simpler in c# .NET Framework 4.0 using Cursor.Position Property
https://docs.microsoft.com/en-us/dotnet/api/system.windows.forms.cursor.position?view=netcore-3.1
public static void ClickSomePoint()
{
// get mouse position
System.Drawing.Point screenPos = System.Windows.Forms.Cursor.Position;
// create X,Y point (0,0) explicitly with System.Drawing
System.Drawing.Point leftTop = new System.Drawing.Point(0,0);
// set mouse position
Cursor.Position = leftTop;
Console.WriteLine(screenPos);
}
这篇关于如何在 C# 中将鼠标光标位置设置为屏幕上的指定点?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文