如果我知道X坐标和Y坐标,是否有一个Windows API或.NET中的一些技术,我可以使用它来使鼠标指针移动到该点?你可以强制鼠标移动吗?
我知道必须有东西,因为有些工具看起来像是在跳鼠标。但我不知道这些API是否可以通过.Net轻松访问。 有吗?
请假定WPF,.Net和Windows(当然)。
解决方案
public Window1()
{
InitializeComponent();
NativeMethods.SetCursorPos(300, 300);
}
public partial class NativeMethods
{
[System.Runtime.InteropServices.DllImportAttribute("user32.dll",
EntryPoint = "SetCursorPos")]
[return: System.Runtime.InteropServices.MarshalAsAttribute
(System.Runtime.InteropServices.UnmanagedType.Bool)]
public static extern bool SetCursorPos(int X, int Y);
}