UWP C# 鼠标控制与手势

UWP C# mouse control with gestures

我正在研究如何使用深度摄像头识别的手势来控制鼠标光标。我想移动光标并执行鼠标左键单击。如何在 UWP C# 中实现它?

我试过这个用于鼠标移动并且它工作正常,但是没有触发其他对象的事件(用鼠标控制一切都很好):

Window.Current.CoreWindow.PointerPosition = new Point(pointerPosition.X - deltaX, pointerPosition.Y + deltaY);

对于鼠标点击,我试过这个:

    [DllImport("user32.dll", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)]
    public static extern void mouse_event(uint dwFlags, uint dx, uint dy, uint cButtons, uint dwExtraInfo);
    //Mouse actions
    private const uint MOUSEEVENTF_LEFTDOWN = 0x0002;
    private const uint MOUSEEVENTF_LEFTUP = 0x0004;

    public async System.Threading.Tasks.Task DoMouseClickAsync()
    {
        //Call the imported function with the cursor's current position

        await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
        {
            var x = (uint)Window.Current.CoreWindow.PointerPosition.X;
            var y = (uint)Window.Current.CoreWindow.PointerPosition.Y;

            mouse_event(MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_LEFTUP, x, y, 0, 0);
        });
    }

但是没有任何反应。你能给我一个建议吗?)

中所述,mouse_event 不能在 UWP 应用程序中使用(出于明显的安全原因)。