function Get_Sys_idle_Time: Dword;Var plii: TLastInputInfo;Begin plii.cbSize := sizeof(plii); Windows.GetLastInputInfo(plii); Result := (Windows.GetTickCount - plii.dwTime);end;procedure TForm1.Timer1Timer(Sender: TObject);begin If Get_Sys_idle_Time > 5000 Then //5秒无操作,视为离开 Caption := '离开' Else caption := '在线';end;procedure TForm1.FormCreate(Sender: TObject);begin Timer1.Interval := 100; Timer1.Enabled := True;end;