Как найти окно по неполному названию
Автор: Mikel
WEB-сайт: http://forum.vingrad.ru
function TForm1.Find(s: string): hWnd;
var
Wnd: hWnd;
buff: array[0..127] of Char;
begin
Find := 0;
Wnd := GetWindow(Handle, gw_HWndFirst);
while Wnd <> 0 do
begin
if (Wnd <> Application.Handle) and
IsWindowVisible(Wnd) and
(GetWindow(Wnd, gw_Owner) = 0) and
(GetWindowText(Wnd, buff, sizeof(buff)) <> 0) then
begin
GetWindowText(Wnd, buff, sizeof(buff));
if pos(s, StrPas(buff)) > 0 then
begin
Find := Wnd;
Break;
end;
end;
Wnd := GetWindow(Wnd, gw_hWndNext);
end;
end;
|