应该可以,我编了一个程序定时激活一个后台应用程序的窗口,然后点击该窗口的特定区域。下面仅是部分源程序,若觉有用,我可将全部文件打包发到你的信箱里!<br>unit Unit1;<br><br>interface<br><br>uses<br> Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,<br> ExtCtrls, StdCtrls;<br><br>type<br> TGetDot = class(TForm)<br> Timer1: TTimer;<br> Label1: TLabel;<br> procedure Timer1Timer(Sender: TObject);<br> private<br> { Private declarations }<br> public<br> { Public declarations }<br> end;<br><br>var<br> GetDot: TGetDot;<br><br>implementation<br><br>{$R *.DFM}<br><br>procedure TGetDot.Timer1Timer(Sender: TObject);<br>var<br> hCurWindow,CurActiveWindow: HWnd; // 窗口句柄<br> WinText: array [0..255] of char;<br> WinCount:Integer;<br>begin<br> WinCount:=0;<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> //鼠标定位到指定座标 <br> SetCursorPos(720,475);<br> //产生鼠标按键事件<br> mouse_event(MOUSEEVENTF_LEFTDOWN+MOUSEEVENTF_LEFTUP,<br> 720,475,0,GetMessageExtraInfo());<br> //给其他应用程序以事件反应时间<br> sleep(5000);<br> //获取下一窗口<br> hCurWindow:=GetWindow(hCurWindow, GW_HWNDNEXT);<br> end;<br>end;<br>