我有一个笨招,但挺管用的。<br>procedure TGetDot.Timer1Timer(Sender: TObject);<br>var<br> hCurWindow,CurActiveWindow: HWnd; // 窗口句柄<br> WinText: array [0..255] of char;<br>begin<br> CurActiveWindow:=GetActiveWindow();<br> hCurWindow := GetWindow(Handle, GW_HWNDFIRST);<br> // 获取第一个窗口的句柄<br> while hCurWindow <> 0 do<br> begin<br> // 获取窗口的名称,并查找是否为目标窗体,注意窗体标题要准确<br> if GetWindowText(hCurWindow, @WinText, 255)>0 then<br> if ( WinText='民主湖聊天室 - Microsoft Internet Explorer') then<br> begin<br> //激活指定窗口,<br> SendMessage(hCurWindow,WM_SYSCOMMAND,SC_MINIMIZE,0);<br> SendMessage(hCurWindow,WM_SYSCOMMAND,SC_RESTORE,0);<br> //将鼠标控制转到指定窗口,并在指定坐标产生鼠标按键事件<br> SetCapture(hCurWindow);<br> mouse_event(MOUSEEVENTF_LEFTDOWN+MOUSEEVENTF_LEFTUP,<br> 720,475,0,GetMessageExtraInfo());<br> sleep(5000); //给指定程序以反应事件的时间,<br> 可更改为Application.ProcessMessages<br> //激活自身的窗体<br> SendMessage(Form1.Handle,WM_SYSCOMMAND,SC_MINIMIZE,0);<br> SendMessage(Form1.Handle,WM_SYSCOMMAND,SC_RESTORE,0);<br> end;<br> // 获取下一个窗口的句柄<br> hCurWindow:=GetWindow(hCurWindow, GW_HWNDNEXT);<br> end;<br>end;<br>