[Solved] auto click in C# in difrent position of screen [closed]


in WPF you can use this line of code to set mouse position

[System.Runtime.InteropServices.DllImport("user32.dll")]
static extern bool SetCursorPos(int x, int y);

this line to firing the event

[System.Runtime.InteropServices.DllImport("user32.dll")]
static extern void mouse_event(int dwFlags, int dx, int dy, int dwData, int dwExtraInfo);

private const int MOUSEEVENTF_LEFTDOWN = 0x02;
private const int MOUSEEVENTF_LEFTUP = 0x04;

and this for simulate the click mouse

private static void LeftMouseClick(int Xposition, int Yposition)
{
    SetCursorPos(Xposition, Yposition)
    mouse_event(MOUSEEVENTF_LEFTDOWN, Xposition, Yposition, 0, 0);
    mouse_event(MOUSEEVENTF_LEFTUP, Xposition, Yposition, 0, 0);
}

and trigger the click you should call the LeftMouseClick;

for example:

LeftMouseClick(11, 15);

You can see this links about thoes functions

SetCursorPos

mouse_event

solved auto click in C# in difrent position of screen [closed]