Simulating mouse movement (C#)

前端 未结 4 1907
没有蜡笔的小新
没有蜡笔的小新 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:02

    I don't know the game but internally windows sends out messages for mouse move. These are sent by the SendMessage() API call to the application. In C# you would either have to use the same Win32 API directly or perhaps by creating/sending an event? Not sure how to send an event to another running application though.

    The SendMessage() Win32 API call defined in C# would look like this:

    [DllImport("user32.dll")]
            public static extern int SendMessage(
                  int hWnd,     // handle to destination window
                  uint Msg,     // message
                  long wParam,  // first message parameter
                  long lParam   // second message parameter
                  );
    

提交回复
热议问题