views:

66

answers:

2

I want to create... basically a macro program. After you click record, it keeps track of all mouse (and maybe eventually keyboard) activity. Then you can save it, and play it, and the mouse should move and click in the same spots that it did when you were recording it.

I know how to grab global mouse events, but I don't know how to make mice move/click in C#.

A: 

If you just need a tool that already does this you could probably use AutoItRecorder. It will record AutoIt scripts that you can run.

Adam Neal
Its not so much that I need the program, more I want to know how its done. But thanks anyways!
TheAdamGaskins
+3  A: 

you can use the win32 APIs for this

SetCursorPos and mouse_event will alow you to move/click the mouse. look into SendMessage too for keyboard stuff, but its more complex.


[DllImport("user32.dll")]
static extern bool SetCursorPos(int X, int Y);
static extern void mouse_event(uint dwFlags, uint dx, uint dy, uint dwData,
   UIntPtr dwExtraInfo);

jasper
Note that `mouse_event` has been superseded by `SendInput`.
Wim Coenen
@Wim Coenen interesting, never knew that. we live and learn.
jasper
Just what I needed! Thanks!
TheAdamGaskins