0

My cursor.position function works, but when the cursor is focused in a window and hidden ( for example in a game when the cursor hides itself ) it doesn't move... Any solution? My code:

Cursor.Position = new Point(Cursor.Position.X + Xvariable, Cursor.Position.Y + Yvariable);

1 Answers1

0

You can test this one

    [DllImport("user32.dll")]
    static extern void mouse_event(int dwFlags, int dx, int dy, int dwData, int dwExtraInfo);

    private const int MOUSEEVENTF_MOVE = 0x0001;

    public static void Move(int xDelta, int yDelta)
    {
        mouse_event(MOUSEEVENTF_MOVE, xDelta, yDelta, 0, 0);
    }

Usage Move(830, 160);

Reference

mrbm
  • 1,136
  • 1
  • 12
  • 36