Move mouse with c#

前端 未结 2 1097
星月不相逢
星月不相逢 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);
    
    0 讨论(0)
  • 2020-12-06 13:40

    You have to use SendInput

    http://inputsimulator.codeplex.com/ makes it somewhat easy

    0 讨论(0)
提交回复
热议问题