I know its popular question. anyway. i want to click button on form of other proccess, i cant get handle of button via spy++, so i will simulate mouse click. what i get:
this is global coordinates of point, i want click:
doubleclickcoords = (MSLLHOOKSTRUCT)Marshal.PtrToStructure(lParam, typeof(MSLLHOOKSTRUCT));
after that i get coordinates of form, let it be "mspaint", and find local coordinates of point, and via postmessage trying to send "click", but nothing happens. what am i missing??:
public static void SendDoubleMouseClick()
{
IntPtr iHandle = GetWnd("mspaint");
Rectangle myRect = new Rectangle();
RECT rct;
if (!GetWindowRect(iHandle, out rct))
{
MessageBox.Show("ERROR");
}
else
{
myRect.X = rct.Left;
myRect.Y = rct.Top;
myRect.Width = rct.Right - rct.Left;
myRect.Height = rct.Bottom - rct.Top;
}
PostMessage(iHandle, 0x0201, 0, new IntPtr((doubleclickcoords.pt.y - myRect.Y) * 0x10000 + (doubleclickcoords.pt.x - myRect.X)));
PostMessage(iHandle, 0x0202, 0, new IntPtr((doubleclickcoords.pt.y - myRect.Y) * 0x10000 + (doubleclickcoords.pt.x - myRect.X)));
}
EDIT: language is c#, winapi via p/invoke