zoukankan      html  css  js  c++  java
  • Webbrowser中模拟连接点击(非鼠标模拟)

    1. uses  
    2.   mshtml, ActiveX;  
    3.   
    4. //初始加载网易主页  
    5. procedure TForm1.FormCreate(Sender: TObject);  
    6. begin  
    7.   Webbrowser1.Navigate('http://www.163.com/');  
    8. end;  
    9.   
    10. procedure TForm1.Button1Click(Sender: TObject);  
    11. var  
    12. I: Integer;  
    13. Document: IHTMLDocument2;  
    14. Element: IHTMLElement;  
    15. Anchors: IHTMLElementCollection;  
    16. sLink: string;  
    17. begin  
    18.    //查找网易新闻页面链接  
    19.    sLink := 'http://news.163.com/';  
    20.    Document := Webbrowser1.Document as IHTMLDocument2;  
    21.    if Assigned(Document) then  
    22.    begin  
    23.       Anchors := Document.Get_links;  
    24.       //遍历所有链接  
    25.       for i := 0 to Anchors.length - 1 do  
    26.       begin  
    27.          Element := Anchors.item(i, varempty) as IHTMLElement;  
    28.          //找到指定链接  
    29.          if Assigned(Element) and (UpperCase((Element as IHTMLAnchorElement).href) = UpperCase(sLink)) then  
    30.         begin  
    31.            //执行点击  
    32.            Element.Click;  
    33.            Break;  
    34.         end;  
    35.       end;  
    36.    end;  
    37. end;  
  • 相关阅读:
    使用pull解析XML文件
    使用Pull解析器生成XML文件
    Android下文件访问的权限
    Android之SharedPreference存储数据
    Android之外部存储(SD卡)
    Android的内部存储
    Android数据存储的方式
    点击事件的四种写法
    Context
    EclipseADT编写单元测试代码的步骤
  • 原文地址:https://www.cnblogs.com/jxgxy/p/2348285.html
Copyright © 2011-2022 走看看