【发布时间】:2017-06-10 04:05:03
【问题描述】:
有没有办法在 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没有这个功能?
我看到有 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);
}
【问题讨论】:
标签: c# uwp raspberry-pi win-universal-app windowsiot