Move mouse with c#

前端 未结 2 1103
星月不相逢
星月不相逢 2020-12-06 12:59

I have a two dimensional array with coordinates and i want to make the mouse move with the specific pattern those coordinates create in a WPF application. Can you help me? I

2条回答
  •  失恋的感觉
    2020-12-06 13:40

    I'm not entirely sure if there is a better way to do it in WPF (It seems the code you are using is targeted at WinForms), but using Platform Invoke on SetCursorPos seems to do the trick:

    private void SetPosition(int a, int b)
    {
        SetCursorPos(a, b);
    }
    
    [DllImport("User32.dll")]
    private static extern bool SetCursorPos(int X, int Y);
    

提交回复
热议问题