C # Programmatic Mouse Movement / Clicks

I want to create ... basically a macro program. After you click on a record , it tracks all mouse activity (and, possibly, the end of the keyboard). Then you can save and play , and the mouse should move and click in the same places that it was when you recorded it.

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

+3
source share
2 answers

you can use win32 APIs for this

SetCursorPos mouse_event / . SendMessage , .


[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);

+4
0

Source: https://habr.com/ru/post/1770914/


All Articles