Пятница, 19.04.2024, 10:10 Приветствую вас Гость | Группа "Гости" 
[ Новые сообщения · Участники · Правила форума · Поиск · RSS ]
  • Страница 1 из 1
  • 1
Модератор форума: Anton93  
delphicode » Delphi » Процедуры и функции Delphi » Нажать на кнопку в другом приложении
Нажать на кнопку в другом приложении
dolphinДата: Суббота, 14.03.2009, 20:42 | Сообщение # 1
Администратор
Сообщений: 906
Статус: Offline
function EnumChildProc(Wnd: hWnd; SL: TStrings): BOOL; stdcall;
var
szFull: array[0..MAX_PATH] of Char; //Buffer for window caption
begin
Result := Wnd <> 0;
if Result then
begin
GetWindowText(Wnd, szFull, SizeOf(szFull)); // put window text in buffer
if (Pos(SL[0], StrPas(szFull)) > 0) // Test for text
and (SL.IndexOfObject(TObject(Wnd)) < 0) // Test for duplicate handles
then SL.AddObject(StrPas(szFull), TObject(Wnd)); // Add item to list
EnumChildWindows(Wnd, @EnumChildProc, Longint(SL)); //Recurse into child windows
end;
end;

function ClickButton(ParentWindow: Hwnd; ButtonCaption: string): Boolean;
var
SL: TStringList;
H: hWnd;
begin
SL := TStringList.Create;
try
SL.AddObject(ButtonCaption, nil); // First item in list is text to find
EnumChildWindows(ParentWindow, @EnumChildProc, Longint(SL));
H := 0;
case SL.Count of
1: ShowMessage('Window text not found.');
2: H := hWnd(SL.Objects[1]);
else
ShowMessage('Ambiguous text detected.');
end;
finally
SL.Free;
end;
Result := H <> 0;
if Result then PostMessage(H, BM_CLICK, 0, 0);
end;

// Rememeber the ampresand for underlined characters
// if the ‘c’ is underlined, then the text is ‘&click’


Система: Windows 10 x64, Kali Linux
Среды программирования: Delphi 7, Delphi 10.x

Я не профессионал, я всего лишь любитель
Я не вредитель, я всего лишь теоретик
 
papsikДата: Понедельник, 13.04.2020, 10:04 | Сообщение # 2
Частый гость
Зарегистрирован: 10.03.2020
Группа: Пользователи
Сообщений: 50
Статус: Offline
полезно!
 
delphicode » Delphi » Процедуры и функции Delphi » Нажать на кнопку в другом приложении
  • Страница 1 из 1
  • 1
Поиск:

delphicode.ru © 2008 - 2024 Хостинг от uCoz