有没有办法模拟 Windows IoT 上特定坐标的点击?
我尝试使用 mouse_event:
mouse_event(MOUSEEVENTF_LEFTDOWN, x, y, 0, 0);
但是,我收到此错误:
System.EntryPointNotFoundException: 'Unable to find an entry point named 'mouse_event' in DLL 'user32.dll'.'.
是因为Windows的IoT版本中不存在该功能吗?
我看到有 SendInput,但文档中唯一的语法是 C++。是否可以在 Windows IoT 上的 C# 中使用它?如果可以,如何使用?如果您心中有一个示例,那么链接它会非常有帮助。我四处搜寻,但找不到可以在 UWP 上运行的东西。
这是我用于 mouse_event 的代码:
[System.Runtime.InteropServices.DllImport("user32.dll", EntryPoint = "SetCursorPos")]
private static extern bool SetCursorPos(int X, int Y);
[System.Runtime.InteropServices.DllImport("user32.dll")]
public static extern void mouse_event(int dwFlags, int dx, int dy, int cButtons, int dwExtraInfo);
public const int MOUSEEVENTF_LEFTDOWN = 0x02;
public const int MOUSEEVENTF_LEFTUP = 0x04;
public const int MOUSEEVENTF_RIGHTDOWN = 0x08;
public const int MOUSEEVENTF_RIGHTUP = 0x10;
//...
public void Click(int x, int y)
{
SetCursorPos(x,y);
mouse_event(MOUSEEVENTF_LEFTDOWN, x, y, 0, 0);
mouse_event(MOUSEEVENTF_LEFTUP, x, y, 0, 0);
}