Skip to content

Commit

Permalink
Windows 锁屏时暂停定时锁定功能
Browse files Browse the repository at this point in the history
  • Loading branch information
JiuLing-zhang committed Feb 7, 2024
1 parent ff38022 commit 5352f45
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/WindowMain.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using ComputerLock.Platforms;
using ComputerLock.Resources;
using JiuLing.CommonLibs.Log;
using Microsoft.Win32;

namespace ComputerLock;
public partial class WindowMain : Window, IDisposable
Expand Down Expand Up @@ -54,6 +55,21 @@ public WindowMain(KeyboardHook keyboardHook, AppSettings appSettings, ILocker lo
};
_logger.Write("自动锁定 -> 启动空闲检测");
_activityMonitor.StartMonitoring();

_logger.Write("自动锁定 -> 准备监控系统会话状态");
SystemEvents.SessionSwitch += (_, e) =>
{
if (e.Reason == SessionSwitchReason.SessionLock)
{
_logger.Write("Windows系统锁定 -> 暂停空闲检测");
_activityMonitor.StopMonitoring();
}
else if (e.Reason == SessionSwitchReason.SessionUnlock)
{
_logger.Write("Windows系统解锁 -> 启动空闲检测");
_activityMonitor.StartMonitoring();
}
};
}

}
Expand Down

0 comments on commit 5352f45

Please sign in to comment.