I am doing a simple system, in this FORM has 2 button, one that executes the function and another that I put a SHOWMESSAGE('teste ok');
and I got the POSITION of that second BUTTON, remembering that I need to use SENDMESSAGE
for the CURSOR of the MOUSE move on the screen, then did the following program:
Procedure SendMouseClick(x,y:Integer);
var
h:THandle;
begin
h := FindWindow(nil, 'TForm1');
SendMessage(h, WM_LBUTTONDOWN, MK_LBUTTON, MAKELPARAM(x,y));
sleep(10);
SendMessage(h, WM_LBUTTONUP, MK_LBUTTON, MAKELPARAM(x,y));
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
SendMouseClick(1042,538);
end;
It turns out that I click and simply do nothing in my FORM. What can I be wrong?