I want my web page to perform an action every time the user Locks (Logoff) or Unlocks (Logon) the Windows session. If I'm able to recurrently call a JS code that checks the session status and do something based on the result, that would work too.
I got the first option to work with C#:
SystemEvents.SessionSwitch += new SessionSwitchEventHandler(SystemEvents_SessionSwitch);
static void SystemEvents_SessionSwitch(object sender, SessionSwitchEventArgs e)
{
if (e.Reason == SessionSwitchReason.SessionLock)
{
// Do something
{
}
Unfortunately, through this method I'm only able to perform an action on my C# program and not on a web page.
Any idea of how I could achieve one of the following?
EDIT: Please note I'm talking about the Windows (OS) session, not the browser window session.
I created a Windows Service which registers the Windows session in a file, then I am reading the file from the web page. Problem solved.