Simulating mouse movement (C#)

前端 未结 4 1878
没有蜡笔的小新
没有蜡笔的小新 2020-12-18 08:46

How would I go about making a small program that keeps moving the mouse upwards?


For those who would like to know, tt\'s a tiny one-use thing. I\'m playing Sta

4条回答
  •  北海茫月
    2020-12-18 09:16

    SetCursorPos will do this in unmanaged code. I'm not sure if there's a .NET method to do the same, but you can always use com interop. It's in User32.dll

    [DllImport("user32.dll")]
    static extern bool SetCursorPos(int X, int Y);
    

    a little google produces this as a SetCursorPos equivalent for .net

    System.Windows.Form.Cursor.Position
    

提交回复
热议问题