delphi Webbrowser中模拟连接点击(非鼠标模拟)


本文整理自网络,侵删。

 
uses
  mshtml, ActiveX;

//初始加载主页
procedure TForm1.FormCreate(Sender: TObject);
begin
  Webbrowser1.Navigate('http://www.hao828.com/');
end;

procedure TForm1.Button1Click(Sender: TObject);
var
I: Integer;
Document: IHTMLDocument2;
Element: IHTMLElement;
Anchors: IHTMLElementCollection;
sLink: string;
begin
   //查找页面链接
   sLink := 'http://www.hao828.com/';
   Document := Webbrowser1.Document as IHTMLDocument2;
   if Assigned(Document) then
   begin
      Anchors := Document.Get_links;
      //遍历所有链接
      for i := 0 to Anchors.length - 1 do
      begin
         Element := Anchors.item(i, varempty) as IHTMLElement;
         //找到指定链接
         if Assigned(Element) and (UpperCase((Element as IHTMLAnchorElement).href) = UpperCase(sLink)) then
        begin
           //执行点击
           Element.Click;
           Break;
        end;
      end;
   end;
end;

相关阅读 >>

Delphi 获取所有磁盘盘符列表

Delphi实现win10下Delphi 10.3.1 inline hook 修改mac网卡地址之getadaptersaddresses

Delphi wmi 取硬件信息

Delphi 取文件目录下所有文件名和文件目录名

Delphi图片上写水印文字函数

Delphi获取开机时间代码

Delphi 获取其他进程句柄的几种方法

Delphi 设置本地系统时间

Delphi webservice 中采用 tsoapattachment 传输文件

Delphi changefileext 更改文件的后缀扩展名

更多相关阅读请进入《Delphi》频道 >>



打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...