Posts

Showing posts from January, 2024

User Idle session time

Add-Type @"     using System;     using System.Runtime.InteropServices; "@ # Define the structure for LASTINPUTINFO $StructLASTINPUTINFO = @"     using System;     using System.Runtime.InteropServices;     public struct LASTINPUTINFO {         public uint cbSize;         public uint dwTime;     }     public class UserInput {         [DllImport("user32.dll")]         [return: MarshalAs(UnmanagedType.Bool)]         public static extern bool GetLastInputInfo(ref LASTINPUTINFO plii);         public static uint GetIdleTime() {             LASTINPUTINFO lii = new LASTINPUTINFO();             lii.cbSize = (uint)Marshal.SizeOf(typeof(LASTINPUTINFO));             GetLastInputInfo(ref lii);         ...