跳到主要内容

github/tai

公开

Tai · Windows 软件与网站使用时长统计。上游 Planshit/Tai 的源码镜像,非灵栈原创;MIT 许可。来源:https://github.com/Planshit/Tai 。本次为手动同步,暂不提供安装包。

提交记录
修改Core/Servicers/Instances/Sleepdiscover.cs+41 −25看文件
@@ -58,23 +58,34 @@ namespace Core.Servicers.Instances
5858
5959 public void Start()
6060 {
61删除: timer = new DispatcherTimer();
62删除: timer.Interval = new TimeSpan(0, 5, 0);
63删除:#if DEBUG
64删除: //timer.Interval = new TimeSpan(0, 0, 10);
65删除:#endif
66删除: timer.Tick += Timer_Tick;
67删除: timer.Start();
61新增: StartTimer();
6862
6963 lastPoint = Win32API.GetCursorPosition();
70删除:
7164 playSoundStartTime = DateTime.MinValue;
72删除:
7365 pressKeyboardLastTime = DateTime.Now;
7466
7567 // 设置键盘钩子
7668 Win32API.SetKeyboardHook(keyboardProc);
7769 }
70新增:
71新增: private void StartTimer()
72新增: {
73新增: StopTimer();
74新增: timer = new DispatcherTimer();
75新增: timer.Interval = new TimeSpan(0, 0, 10);
76新增: timer.Tick += Timer_Tick;
77新增: timer.Start();
78新增: }
79新增:
80新增: private void StopTimer()
81新增: {
82新增: if (timer != null)
83新增: {
84新增: timer.Tick -= Timer_Tick;
85新增: timer.Stop();
86新增: }
87新增: }
88新增:
7889 private void SystemEvents_SessionSwitch(object sender, SessionSwitchEventArgs e)
7990 {
8091 if (e.Reason == SessionSwitchReason.RemoteDisconnect || e.Reason == SessionSwitchReason.ConsoleDisconnect)
@@ -235,7 +246,7 @@ namespace Core.Servicers.Instances
235246 SystemEvents.SessionSwitch -= SystemEvents_SessionSwitch;
236247
237248 // 停止离开检测计时器
238删除: timer?.Stop();
249新增: StopTimer();
239250
240251 status = SleepStatus.Sleep;
241252
@@ -252,29 +263,34 @@ namespace Core.Servicers.Instances
252263 {
253264 return;
254265 }
266新增: try
267新增: {
268新增: // 注册事件
269新增: SystemEvents.SessionSwitch += SystemEvents_SessionSwitch;
255270
256删除: // 注册事件
257删除: SystemEvents.SessionSwitch += SystemEvents_SessionSwitch;
258删除:
259删除: status = SleepStatus.Wake;
260删除:
261删除: // 卸载鼠标钩子
262删除: Win32API.UnhookWindowsHookEx(mouseHook);
271新增: status = SleepStatus.Wake;
263272
264删除: // 启动离开检测
265删除: timer.Start();
273新增: // 卸载鼠标钩子
274新增: Win32API.UnhookWindowsHookEx(mouseHook);
266275
276新增: // 启动离开检测
277新增: StartTimer();
267278
268279
269删除: // 重置声音播放时间
270删除: playSoundStartTime = DateTime.MinValue;
271280
272删除: // 重置鼠标坐标
273删除: lastPoint = Win32API.GetCursorPosition();
281新增: // 重置声音播放时间
282新增: playSoundStartTime = DateTime.MinValue;
274283
275删除: // 状态通知
276删除: SleepStatusChanged?.Invoke(status);
284新增: // 重置鼠标坐标
285新增: lastPoint = Win32API.GetCursorPosition();
277286
287新增: // 状态通知
288新增: SleepStatusChanged?.Invoke(status);
289新增: }
290新增: catch (Exception e)
291新增: {
292新增: Logger.Error(e.ToString());
293新增: }
278294 }
279295
280296 /// <summary>