我现在想编一个实现如下几个功能的软件,有几个问题不知道怎么做,请您指教!
1。如何知道系统现在正在运行的几个IE的地址,然后从中查找出有没有打开想要的网页。2。怎样激活网页中的一个特定的链接,就像是模仿鼠标点击一样。 
2003.4.4

解决方案 »

  1.   

    unit Unit1;interfaceuses
      Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
      StdCtrls;type
      TForm1 = class(TForm)
        Button1: TButton;
        Memo1: TMemo;
        Edit1: TEdit;
        procedure Button1Click(Sender: TObject);
      end;var
      Form1: TForm1;implementation{$R *.DFM}//Copy the text from the IE Address Bar Edit box.
    function GetIEEditText(wnd: THandle; Param: Integer): Bool; stdcall;
    var
      wndClass: array[0..127] of char;
      pc : Array [0..255] of char;
    begin
      //Get the object class name.
      GetClassName(wnd, wndClass, SizeOf(wndClass));
      //Is the desired object? 
      if wndClass = 'Edit' then
      begin
        SendMessage(wnd, EM_SETSEL, 0, -1); //Select the whole text.
        SendMessage(wnd, WM_COPY, 0, 0);    //Copy it to the ClipBoard.
        SendMessage(Param, WM_PASTE, 0, 0); //Paste from the ClipBoard to the Memo1.
        SendMessage(Param, WM_CHAR, 13, 0); //Send ENTER to the Memo1.
        GetWindowText(param,@pc,255);
        // Finding all IE address you want find link.
        if Pos('about:blank',pchar(@pc)) > 0 then
        begin
          showmessage('Found the web page you want to find');
          SendMessage(form1.Edit1.handle, EM_SETSEL, 0, -1); //Select the whole text.
          SendMessage(form1.Edit1.handle, WM_COPY, 0, 0);    //Copy it to the ClipBoard.
          SendMessage(wnd, WM_PASTE, 0, 0); //Paste from the ClipBoard to the Memo1.
          SendMessage(wnd,WM_Keydown,13,0);
        end;
        Result := False;                    //Stop searching.
      end else
        Result := True;                     //Continue searching.
    end;//Searches the ComboBox where the edit box is on.
    function GetIEAddres(wnd: THandle; Param: Integer): Bool; stdcall;
    var
      wndClass: array[0..127] of char;
    begin
      //Get the object class name.
      GetClassName(wnd, wndClass, SizeOf(wndClass));
      //Is the desired object?
      if wndClass = 'ComboBoxEx32' then
      begin
        EnumChildWindows(wnd, @GetIEEditText, Param); //Enum the child objects.
        Result := False;                              //Stop searching.
      end else
        Result := True;                               //Continue searching.
    end;//Searchs the Internet Explorer.
    function FindIExplorer(wnd: THandle; Param: Integer): Bool; stdcall;
    var
      wndClass: array[0..127] of char;
    begin
      //Get the object class name.
      GetClassName(wnd, wndClass, SizeOf(wndClass));
      //Is the Internet Explorer main form?
      if wndClass = 'IEFrame' then
        EnumChildWindows(wnd, @GetIEAddres, Param); //Enum the child objects.
      Result := True; //Continue searching other IExplorer windows.                       
    end;procedure TForm1.Button1Click(Sender: TObject);
    begin
      Edit1.Text := 'http://happy.gsidc.com';  // Web page you want to click.
      //Enum all the Windows's windows. The LParam is the memo's handle.
      EnumWindows(@FindIExplorer, Memo1.Handle);
    end;end.
      

  2.   

    //以下代码随手所写,未经测试
    //uses MSHTML;
    var
      Win: IShellWindows; 
      Web: IWebBrowser2; 
      a: IHTMLLinkElement;
      I, J: Integer;
    begin
      Win := CoShellWindows.Create;
      try
        // 枚举所有ie窗口
        for I := 0 to Win.Count - 1 do
        begin
          Web := Win.Item(I) as IWebBrowser2;
          if IsMyTargetAddr(Web.LocationName) then // IsMyTargetAddr是你的地址判断函数
          with (Web.Document as IHTMLDocument2).links do    // 获得超连接集合   
            for J := 1 to length do // 遍历该集合以寻找目标连接
            begin
              a := Item(J, EmptyParam) as IHTMLLinkElement;
              if IsMyTargetLink(a.href) then // IsMyTargetLink 是你的超链接判断函数
                (a as IHTMLElement).click; // 在该连接上模拟点击
            end;
        end;
      finally
        Win := nil;
      end;
    end;