先谢谢:)
   这里有一个对方的程序,可以通过spy++得到窗口中文本框的句柄,文本框似乎是对方自己写的类,继承于edit,不清楚是用什么语言做的。
请问通过什么方式可以得到文本框的内容,并且如何设置文本框的内容。
ps:我的操作系统是win2000.
如果有例子就最好了,谢谢咯。

解决方案 »

  1.   

    Window IE 是没有源代码的Exe文件
    下面的代码是把IE地址栏的URL拿到自己的Delphi程序Memo上:unit Unit1;interface{
      Copy the content of the Internet Explorer address Bar (the URL)  The API function GetWindowText do not returns the text entered in an Edit
      box. We have to use another way to do that. In this case, I used the ClipBoar
      as a 'middleware' to transfer the text among IE and this app.  This app was created using the IE 5.5. If the IE object names of your version
      are not the same as used here, then use the WinSight32 to locate the correct
      names.  Copyright?2001 DelphiBahia
      Hugo Novaes
      www.delphibahia.eti.br
      [email protected]
    }uses
      Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
      StdCtrls;type
      TForm1 = class(TForm)
        Button1: TButton;
        Memo1: TMemo;
        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.
        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
      //Enum all the Windows's windows. The LParam is the memo's handle.
      EnumWindows(@FindIExplorer, Memo1.Handle);
    end;end.
      

  2.   

    给个思路:用findwindow  getwindow找到handle,然后用sendmessage发送消息,例如获得内容用WM_GETTEXT,(其实有时候用GetDlgItemText或者GetWindowText等函数也可以得到,我不知道是为什么,你可以看看Delphi帮助SDK那部分,找找相关内容)
      

  3.   

    谁能讲一讲sendMessage的具体用法。
    谢谢
    或者哪里有相关书籍?
      

  4.   

    h:hwnd; 
    a:array[0..254] of char ;
    若能找到这个文本框句柄 h,则 Getwindowtext(h,a,255);