很简单,看下面一段代码吧:<br> T := GetTickCount;<br> repeat<br> if HPWnd = 0 then<br> HPWnd := FindWindow('TQSAuthorizeForm', nil) //找到那个按钮的父窗体的Handle<br> else<br> HCWnd := FindWindowEx(HPWnd, 0, 'TButton', 'OK');//找到那个按钮,类为TButton,Caption是OK<br> if HPwnd = 0 then<br> Sleep(100)<br> until ((HPWnd > 0) and (HCWnd > 0)) or (GetTickCount - T > 15000); //如果在15秒内两个都找齐了或超时就不理了。<br><br> if ((HPWnd > 0) and (HCWnd > 0)) then//窗体及按钮都找到了<br> SendMessage(HPWnd, WM_COMMAND, 0, HCWnd); //发一条消息说OK按钮被人按下了。<br> end;<br>看明白了?<br><br>