查找APP1的Form1的FormHandle: integer;<br>在Form1中循环查找Edit的EditHandle;<br>sendMessage(EditHandle,WM_SETTEXT,0,Integer(pchar('Your Mesaage')));<br><br>procudure DoSomeThing;<br>var<br> Handle,FormHandle: Integer;<br> tmpHandle: Integer;<br> FindFlag: Boolean;<br> editHandle, ButtonHandle: integer;<br>begin<br> Handle:=0; TmpHandle:=0;<br> edithandle:=0; buttonHandle:=0;<br> FindFlag:=False;<br> while FindFlag=False do<br> begin <br> Handle := FindWindow(nil,'Form1Caption'); <br> if Handle<>0 then<br> begin<br> FindFlag:=True;<br> tmpHandle := Handle;<br> FormHandle:=Handle;<br> repeat<br> EnumChildWindows(Handle,@GetButtonHandle,Integer(@Handle));<br> FButtonHandle := Handle;<br> until FButtonHandle<>FormHandle;<br> repeat<br> EnumChildWindows(tmpHandle,@GetEditHandle,Integer(@tmpHandle));<br> FTextHandle := tmpHandle;<br> until FTextHandle<>FormHandle;<br> SendMessage(FTextHandle,WM_SETTEXT,0,Integer(pchar('Your Message Here')));<br> SendMessage(FButtonHandle,WM_LBUTTONDOWN,0,0);<br> SendMessage(FButtonHandle,WM_LBUTTONUP,0,0);<br> end;<br> end;<br>end;<br><br>function GetEditHandle(hwnd: Integer; lparam: Longint):Boolean; stdcall;<br>var<br> buffer: array[0..255] of Char;<br> buffer1: array[0..255] of Char;<br>begin<br> Result := True; <br> GetClassName(hwnd,buffer,256); <br> if StrPas(Buffer)='Edit' then<br> begin<br> GetWindowText(hwnd,buffer1,100);<br> PInteger(lparam)^ := hwnd; <br> Result:=False;<br> end;<br>end;<br><br>function GetButtonHandle(hwnd: Integer; lparam: Longint):Boolean; stdcall;<br>var<br> buffer: array[0..255] of Char;<br> buffer1: array[0..255] of Char;<br>begin<br> Result := True; <br> GetClassName(hwnd,buffer,256);<br> if StrPas(Buffer)='Button' then<br> begin<br> GetWindowText(hwnd,buffer1,100);<br> if buffer1 = '确定' then<br> begin<br> PInteger(lparam)^ := hwnd;<br> Result:=False; <br> end;<br> end;<br>end;<br><br>待会儿再来