procedure
ClickOnForm(wnd: HWND; caption:
string
);
var
TheChildHandle: HWND;
begin
TheChildHandle := FindWindowEx(wnd,
0
,
nil
,
PChar
(caption));
SendMessage(TheChildHandle, WM_LButtonDown,
1
,
1
);
SendMessage(TheChildHandle, WM_LButtonUP,
1
,
1
);
end
;
procedure
TForm1
.
Button4Click(Sender: TObject);
var
wnd: HWND;
caption:
string
;
begin
wnd := GetTopWindow(
0
);
repeat
SetLength(caption, GetWindowtextLength(wnd));
GetWindowText(wnd, @caption[
1
], length(caption) +
1
);
if
(trim(caption) =
'iCCup Launcher'
)
then
ClickOnForm(wnd,
'Имя кнопки'
);
wnd := GetNextWindow(wnd, GW_HWNDNEXT);
until
wnd =
0
;
end
;