I am trying to send a simulated mouse click to another application. I understand how to actually send the key click, this is not the issue. I need to send the mouse click to the very center of the other application. I can simply test it once and find out the coordinate and send the click to that XY location, but there is an issue... When I move the window, or resize this window the XY coordinates will obviously not be the same.
So I need to find out how to get the size of the window, and its location and then find the center point from this. Anyone know how to do this? Thank you very much to any response!
Here is my code to send the mouse click
public void SendLeftClick(int x, int y)
{
int old_x, old_y;
old_x = Cursor.Position.X;
old_y = Cursor.Position.Y;
SetCursorPos(x, y);
mouse_event(MouseEventFlag.LeftDown, x, y, 0, UIntPtr.Zero);
mouse_event(MouseEventFlag.LeftUp, x, y, 0, UIntPtr.Zero);
SetCursorPos(old_x, old_y);
}