用VC编程,如何得到用户在另外一个程序的文本框中输入的文字?

解决方案 »

  1.   

    老办法
    先找到另外一个程序的句柄
    然后用EnumChildWindows来枚举得到那个文本框的句柄
    再发WM_GETTEXT消息给文本框的句柄就可以得到了
      

  2.   

    为什么用GetWindowText得到的是空字符串?
      

  3.   

    int GetWindowText(
      HWND hWnd,        // handle to window or control
      LPTSTR lpString,  // text buffer
      int nMaxCount     // maximum number of characters to copy
    );
    If the target window is owned by the current process, GetWindowText causes a WM_GETTEXT message to be sent to the specified window or control. If the target window is owned by another process and has a caption, GetWindowText retrieves the window caption text. If the window does not have a caption, the return value is a null string. This behavior is by design. It allows applications to call GetWindowText without hanging if the process that owns the target window is hung. However, if the target window is hung and it belongs to the calling application, GetWindowText will hang the calling application. To retrieve the text of a control in another process, send a WM_GETTEXT message directly instead of calling GetWindowText.
      

  4.   

    If the target window is owned by the current process, GetWindowText causes a WM_GETTEXT message to be sent to the specified window or control. If the target window is owned by another process and has a caption, GetWindowText retrieves the window caption text. If the window does not have a caption, the return value is a null string. To retrieve the text of a control in another process, send a WM_GETTEXT message directly instead of calling GetWindowText. 
      

  5.   

    就是说GetWindowText会引起进程悬停。就是进程“假死”状态。
      

  6.   

    future0723(大连流氓),呵呵,都是抄MSDN上的,让你赶了一点点先,唉,网速太慢!
      

  7.   

    in 2K system ,you should use dll hook,and use API:
    SendMessage(hwnd,WM_GETTEXT,buf,size);
      

  8.   

    in two aplication regist the same ID message, sendmessage from one to the other ,you can do it .
    ================================================================CSDN 论坛助手 Ver 1.0 B0402提供下载。 改进了很多,功能完备!★  浏览帖子速度极快![建议系统使用ie5.5以上]。 ★  多种帖子实现界面。 
    ★  保存帖子到本地[html格式]★  监视您关注帖子的回复更新。
    ★  可以直接发贴、回复帖子★  采用XML接口,可以一次性显示4页帖子,同时支持自定义每次显示帖子数量。可以浏览历史记录! 
    ★  支持在线检测程序升级情况,可及时获得程序更新的信息。★★ 签名  ●  
         可以在您的每个帖子的后面自动加上一个自己设计的签名哟。Http://www.ChinaOK.net/csdn/csdn.zip
    Http://www.ChinaOK.net/csdn/csdn.rar
    Http://www.ChinaOK.net/csdn/csdn.exe    [自解压]