Delphi_Webbrowser中自动点击Alert弹出窗口中的按钮

function CallBackProc(H, HMainForm: hwnd): Boolean; stdcall;
var
  hChild: hwnd;
begin
  Result := True;
  if GetParent(H) = HMainForm then begin
    hChild := FindWindowEx(H, 0, PChar('Button'), PChar('OK'));
    if hChild > 0 then SendMessage(hChild, BM_Click, 0, 0);
  end;

end;


procedure TForm1.Timer1Timer(Sender: TObject);
begin
  EnumWindows(@CallBackProc, Self.Handle);
end;

你可能感兴趣的:(Delphi_Webbrowser中自动点击Alert弹出窗口中的按钮)