转:http://ymg97526.blog.163.com/blog/static/17365816020101021703631/
//添加一个TApplicationEvents组件
//OnMessage:控制着整个应用程序的消息循环
//OnIdle:应用程序空闲时触发
procedure TForm1.ApplicationEvents1Idle(Sender: TObject; var Done: Boolean);
begin
Memo1.Lines.Add('Application Idled.');
end;
procedure TForm1.ApplicationEvents1Message(var Msg: tagMSG;
var Handled: Boolean);
begin
Memo1.Lines.Add(Format('X=%d;Y=%d',[Msg.pt.X,Msg.pt.Y]));
end;