to znxia感谢,很好,已通过调试。再请您解释一下,我原来采用的代码为什么不对?一执行就造成被控端失去响应,如果被控端在D7下用F9运行时,连D7都不能终止。仿网络资料试验的代码:function GetButtonHandle(hwnd:integer;lparam:longint):boolean;stdcall; //stdcall什么意思?var buffer:array[0..255] of char; buffer1:array[0..255] of char;begin result:=true; GetClassName(hwnd,buffer,256); //取得hwnd参数提供的句柄的类名并赋值给buffer且是长度256的char类型,对吧? if strPas(buffer)='button' then begin GetWindowText(hwnd,buffer1,100); if buffer1='目标按钮' then begin PInteger(lparam)^:=hwnd; //这句什么意思? ^:=什么意思? result:=false; end; end;end;procedure TForm1.Button1Click(Sender: TObject);var buttonHandle,WindowHandle:hwnd;begin windowhandle:=findwindow(nil,'被控制'); if windowHandle <> 0 then begin EnumchildWindows(windowhandle,@getbuttonhandle,integer(@windowhandle));//详细解释这句,都不会 buttonhandle:=windowhandle; if buttonhandle <> 0 then begin sendmessage(buttonhandle,MOUSEEVENTF_LEFTDOWN,0,0); sendmessage(buttonhandle,MOUSEEVENTF_LEFTUP,0,0); end; end;end;您给我的代码procedure TForm1.Button2Click(Sender: TObject);var h:hwnd; m
char;begin h:=findwindow(nil,'被控制'); if h<>0 then begin m:=stralloc(30); getclassname(h,m,30); showmessage(strpas(m)); end else showmessage('无'); h:=getwindow(h,gw_child); while h<>0 do begin windows.GetWindowText(h,m,30); showmessage(strpas(m)); postmessage(h,wm_lbuttondown,0,0); postmessage(h,wm_lbuttonup,0,0); h:=getwindow(h,gw_hwndnext); end; strdispose(m);end;如果被控制的窗体上有多个按钮呢?如果按下按钮后又有弹出窗体上的按钮需要自动按下呢?请给个能运行的例子吧,感激不尽。想念大富翁们,那些老人哪去了?退休了?没有你们就没有我的进步,回来聚聚吧。