第一步:找到Button所在窗口句柄:<br>var H : THandle;<br>H := FindWindow( nil, '程序Caption' );<br>第二步:找到Button句柄:<br>EnumChildWindows( H, @EnumerateChildWindows, 0 );<br>第三步:发送消息:<br>Sendmessage(H,WM_...,0,0);<br>程序参考:<br><br>//回调函数,列出所有子窗口句柄<br>var<br> HEdt : THandle;<br>function EnumerateChildWindows(hWnd: HWND; lParam: LPARAM): BOOL;<br>var<br> WindowCaption:array[0..254] of Char;<br>begin<br> GetWindowText(Hwnd,WindowCaption,255);<br> if WindowCaption = '是我要的' then <br> HEdt := hWnd;<br> Result:=TRUE;<br>end;<br><br>procedure TFindForm.Button2Click(Sender: TObject);<br>var<br> H : HWnd;<br> I : Integer;<br>begin<br> H := FindWindow( nil, '程序Caption');<br> if H = 0 then exit;<br> EnumChildWindows( H, @EnumerateChildWindows, 0 );<br> SendMessage( HEdt, WM_SETTEXT, 255, LongInt(PChar('afdasf');<br> SendMessage( HBtn, BM_CLICK, 0, 0 );<br>end;