I have some code in delphi that clicks a button in a window.The way it does that: it gets the hwnd of the window,then it enums all the childs,if any of them has text with "ok"(the button i want),it sends some messages.Full code:
function EnumChildProc_Register(AHWND: HWND; AParam: LParam): Boolean; stdcall;
const
BUFFER_SIZE = 4096;
var
text : array[0..BUFFER_SIZE - 1] of Char;
pparam: pointer;
res : DWORD;
begin
pparam := pointer(AParam);
SendMessageTimeout(AHWND, WM_GETTEXT, BUFFER_SIZE, NativeUint(@text[0]), SMTO_ABORTIFHUNG, 50, @res);
if String(text) = 'OK' then
begin
PostMessage(AHWND, WM_KEYDOWN, VK_RETURN, 0);
Sleep(10);
PostMessage(AHWND, WM_KEYUP, VK_RETURN, 0);
Boolean(pparam^) := FALSE;
end;
result := Boolean(pparam^);
end;
The big problem is,those 2 post messages do nothing in win32.I tested the code,and the button is not clicked.How could it work in delphi,and in c++ not?