如何在UWP应用程序中移动鼠标? [英] How can I move the mouse in a UWP app?

查看:298
本文介绍了如何在UWP应用程序中移动鼠标?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有System.Windows.Forms.Cursor.Position属性,您可以使用它来移动鼠标,但不能在不使用.NET Framework的UWP应用程序中使用它。
有什么类似的,你可以使用移动鼠标在UWP应用程序?

There is the System.Windows.Forms.Cursor.Position property which you can use to move the mouse, but you can't use that in a UWP app that does not use the .NET Framework. Is there anything like this that you can use to move the mouse in a UWP app?

推荐答案

System.Windows.Forms.Cursor.Position 不能在UWP中使用。您可以使用 CoreWindow.PointerPosition 设置鼠标的位置。当您将 Point 设置为 CoreWindow.PointerPosition 时,鼠标可以移动到新位置。

As you know System.Windows.Forms.Cursor.Position can not be used in UWP. You can use CoreWindow.PointerPosition to set the location of mouse. The mouse can move to the new location, when you set the new Point to the CoreWindow.PointerPosition.


当出现锁定屏幕时,无法使用此API读取指针位置。

You can not read the pointer position with this API when the lock screen is present.

有关详情,请参阅 CoreWindow.PointerPosition

例如:

Window.Current.CoreWindow.PointerPosition = new Point(500, 500);

这篇关于如何在UWP应用程序中移动鼠标?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆