1,如何得到目标窗体中选中的文本?目标窗体是外部程序,和Ctrl+C可以把选中文本
  复制到剪切板中相类似。我的目的是用消息(WM_COPY??)或枚举等一切可用的方法,
  在程序中得到文本。(实在不行,也可以考虑用剪切板)。2,GetActiveWindow 和 GetForegroundWindow 有什么区别?3,如果有WM_COPY 消息,如何使用,主要是它的wParam,lParam如何设置。   谢谢!欢迎指导!!!

解决方案 »

  1.   

    1.获得handle,发送wm_copy消息就可以了,下面是获得一个记事本的选中的文本到memo控件里面
    procedure TForm1.Button2Click(Sender: TObject);
    var
     h:HWND;
    begin
       h:=findWindow(pchar('Notepad'),nil);   h:=getwindow(h,GW_CHILD);
       sendmessage(h,WM_COPY,0,0);
       memo1.PasteFromClipboard;
    end;
    2。The GetActiveWindow function retrieves the window handle to the active window associated with the calling thread's message queue. The GetForegroundWindow function returns a handle to the foreground window (the window with which the user is currently working). The system assigns a slightly higher priority to the thread that creates the foreground window than it does to other threads. 
    据我的理解是getactivewindow市获得活动窗口,getforegrondwindow是获得前台窗口
    活动窗口不止一个,但是前台窗口只有一个
    3。看帮助阿
    WM_COPY
    An application sends the WM_COPY message to an edit control or combo box to copy the current selection to the clipboard in CF_TEXT format. WM_COPY 
    wParam = 0; // not used; must be zero 
    lParam = 0; // not used; must be zero 
     
    这两个参数都用不上的
      

  2.   

    to: ghostmirror(mirror) ( ) 你指的帮助是DELPHI的吗,我怎么没有找到呀? 你是怎么搜到的?