Mouse motion simulation (C #)

How can I make a small program that moves the mouse up?


For those who would like to know, a tiny one-time thing. I play Star Wars The Force Unleashed. In console versions, you hold the right stick up. You are using a mouse in a poor console port on a PC. Maybe you can understand my disappointment.

+3
source share
4 answers

SetCursorPos will do this in unmanaged code. I'm not sure if there is a .NET way to do this, but you can always use com interop. This is in user32.dll

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

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

 System.Windows.Form.Cursor.Position 
+9
source

This is a problem for mechanical programming, not CSharp.

  • You need to connect a second mouse, and get a cheap variable speed drill.
  • Place the grinding drum on the drill, wrap it in striped paper, and set it to the lowest speed.
  • Then place the bracket on the non-rotating body of the drill, which will hold the mouse with a sensor close to the rotating striped paper.
  • Make sure the mouse is facing up to simulate upward movement.

To execute the program, turn the power switch on the power strip into which the drill is inserted.

Edit: if you want to use a more portable code, use a cordless drill. Batteries are not included.

+14
source

I do not know the game, but the internal windows send messages to move the mouse. They are sent by calling the SendMessage() API for the application. In C #, will you have to either use the same Win32 API directly, or perhaps by creating / sending an event? Not sure how to send the event to another running application.

The Win32 SendMessage () API call defined in C # will 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 ); 
+3
source

Have you tried to use a controller or joystick?

http://www.merconnet.com/product_info.php?products_id=44

+2
source

All Articles