//改一改,改为这样可以输入中文了吧。<br><br>procedure TForm1.Button1Click(Sender: TObject);<br> function EnumChildWindowsProc(hwnd: Integer; lparam: Longint):Boolean; stdcall;<br> var<br> buffer: array[0..255] of Char;<br> begin<br> Result := True;<br> //得到目标窗口的控件<br> GetClassName(hwnd,buffer,256);<br> //找到发消息的目标窗口的目标控件<br> if StrPas(Buffer)='Edit' then<br> begin<br> PInteger(lparam)^ := hwnd; //得到目标控件的Hwnd(句柄)<br> Result:=False; //终止循环<br> end;<br> end;<br>var<br> Handle: Integer;<br> buffer: Array[0..1023] of Char;<br> i: integer;<br> s: string;<br>begin<br> Handle := FindWindow('NotePad',nil);<br> if Handle<>0 then<br> begin //<br> EnumChildWindows(Handle,@EnumChildWindowsProc,Integer(@Handle));<br> SendMessage(Handle, EM_SETSEL, 0, -1); //选取ALL<br> SendMessage(Handle, WM_CUT, 0, 0); //剪切到剪贴板<br> SendMessage(Handle,WM_SETTEXT,0,Integer(pchar('字符串')));<br> SendMessage(Handle, WM_PASTE, 0, 0); //从剪贴板贴回来<br> end;<br>end;