首先你可以使用FindWindow,GetWindow 等手段得到程序(form)的句柄<br>然后再用SendMessage或PostMessage的方法,将字符串传过去。<br>以下一段例子是将PhotoShop 打开并点击某菜单,在弹出的窗口中<br>选择一段字符串,并将它改变的例子<br><br>function fun_GetImageSize: TImageSize;<br>var<br> ISH: THandle;<br> CancelHandle: THandle;<br> WidthHandle : THandle;<br> HeightHandle: THandle;<br> TextW: array [0..255] of Char;<br> TextH: array [0..255] of Char;<br>begin<br> // Step 1: Call PS to show the 'Image Size' dialog.<br> prc_MenuClick(2,8,-1);<br> // Step 2: If success,get the two Edit's handles.<br> repeat<br> Application.ProcessMessages;<br> ISH:= FindWindow(PChar('PSFloatC'),PChar('Image Size'));<br> until ISH <> 0 ;<br><br> repeat<br> Application.ProcessMessages;<br> CancelHandle:= FindWindowEx(ISH,0,PChar('Button'),Pchar('Cancel'));<br> WidthHandle:= FindWindowEx(ISH,0,PChar('Edit'),nil);<br> HeightHandle:= FindWindowEx(ISH,WidthHandle,PChar('Edit'),nil);<br> Until ((CancelHandle<>0) and (WidthHandle<>0) and (HeightHandle<>0));<br><br> SendMessage(WidthHandle,WM_GETTEXT,Sizeof(TextW),LongInt(@TextW));<br> SendMessage(HeightHandle,WM_GETTEXT,Sizeof(TextH),LongInt(@TextH));<br> Form1.Hint:= TextW;<br> Result.X:= StrToInt(Form1.Hint);<br> Form1.Hint:= TextH;<br> Result.Y:= StrToInt(Form1.Hint);<br> Form1.Hint:='';<br> PostMessage(CancelHandle,BM_CLICK,0,0); //After Use, Close it.<br><br>end;