John Rood
John Rood

Reputation: 835

How can I set the mouse cursor position in a UWP app?

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?

Upvotes: 2

Views: 3423

Answers (1)

Jayden
Jayden

Reputation: 3286

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.

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

For more info, see CoreWindow.PointerPosition

For example:

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

Upvotes: 4

Related Questions