我想写一个程序,在程序执行后如果长时间没有操作鼠标、键盘等,就自动运行另一任务,DELPHI7教程中介绍了TApplication.OnIdle事件,就是指应用程序在空闲状态时触发,可不知道怎么写脚本?

解决方案 »

  1.   

    這個才是你要的:...check, how long the system is Idle?  
     
    function LastInput: DWord;
    var
      LInput: TLastInputInfo;
    begin
      LInput.cbSize := SizeOf(TLastInputInfo);
      GetLastInputInfo(LInput);
      Result := GetTickCount - LInput.dwTime;
    end;//Example:
    procedure TForm1.Timer1Timer(Sender: TObject);
    begin
      Label1.Caption := Format('System Idle since %d ms', [LastInput]);
    end;
    // The GetLastInputInfo function retrieves the time
    // of the last input event.
    // Minimum operating systems: Windows 2000
      

  2.   

    以上都不是我题目的正确回答!就没有看懂我的问题的高手吗?我是说TApplication.OnIdle事件如何使用?所问非所答呀
      

  3.   

    to fanguluke(fan):
       你说的这个事件和我说的不是一回事,你说的通信端口接收到一个数据可以用‘时间控件’timer就可以随时检测到的,我的说是应用程序处于空闲状态时触发的事件:只要应用程序在规定的时间内没有键盘、鼠标操作,就触发一个事件,执行某一任务,这个事件就是TApplication.OnIdle事件,但我不知道怎么去写这个事件的脚本。