有遍历的就行.<br>function EnumProc(hwnd:Thandle;lparam:lparam):boolean; Stdcall;<br>var<br> lpText,lpCaption :array[0..255] of char;<br><br>begin<br> Result := true;<br> GetClassName(hwnd,@lpText,255);//得到类名。<br> if LowerCase(lpText)=lowercase('tbutton') then<br>//这个用类别来查找。这里举例用TBUTTON<br> begin<br> Hchild := hwnd;<br> GetWindowText(Hchild,lpCaption,100);<br> if trim(lpCaption)='按钮的CAPTION写在这里' then//在这边用CAPTION来查找<br> Result := false//打到返回FALSE<br> else<br> Result := true;<br> end;<br>end;<br><br>function TForm1.GetEditHandle(WinCap:string):integer;<br>var<br> hParent :Thandle;<br> i :integer;<br>begin<br> Result := 0;<br> Hchild := 0;<br> hParent := FindWindow(nil,pchar(''));//窗体的名称写在这边<br> if hParent=0 then Exit;<br> EnumChildWindows(hParent,@EnumProc,0);//回调EnumProc<br> Result := Hchild;<br><br>end;<br>也可用<br>var<br> H1,H2:THandle;<br>begin<br> H1:=FindWindow('TForm1','shenqw');<br> H2:=Findwindowex(H1,0,'TButton','Button1');<br> SendMessage(H2,bm_click,0,0);<br>end;