'Setting Cursor.Position in Windows 10 not working

I want to set the mouse cursor to a certain position by using:

Cursor.Position = new Point(Int32.Parse(X), Int32.Parse(Y));

This works normally in Windows 7, but not in Windows 10. The cursor is not moving, but when the position is on a button you can see the hover reaction.

Is this a known issue? If yes, is there a workaround for this?

Thanks in advance

EDIT 1: This seems to be a visual problem meaning only the visible cursor does not move. For test purposes I have created a button (button_1) which performs above code on a click. I set the X and Y coordinates to be on another button (button_2). Now when I click button_1 button_2 gets highlighted as if the cursor is hovering on it. If I click button_1 again without moving the mouse, button_2 gets clicked. When I move the mouse between the clicks button_2 is not highlighted anymore. Thus, resulting in the second click doing the same as the first.

EDIT 2 I tried using the following function instead of Cursor.Position, but with the same result.

[DllImport("User32.Dll")]
public static extern long SetCursorPos(int x, int y);


Solution 1:[1]

Ok so this is not a Windows 10 problem. I did not realize that this issue could have something to do with the fact that I was working in a VM. Consider this as solved.

Solution 2:[2]

One thing I noticed is that you need to execute the program as a system administrator if the external application also requires to run as a system administrator. Otherwise, Cursor doesn't work on the external application. This issue occurs in Windows 10 but not in Windows 7.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Flavio G.
Solution 2 Guor-Yieh Luo