Tweaks and fixes

This commit is contained in:
Serge
2023-05-24 14:34:43 +02:00
parent f395c706f6
commit e765b4f037
9 changed files with 152 additions and 96 deletions

View File

@@ -2,6 +2,7 @@
using System.ComponentModel;
using System.Diagnostics;
using System.Runtime.InteropServices;
using static System.Windows.Forms.VisualStyles.VisualStyleElement.TrackBar;
using static Tools.ScreenInterrogatory;
namespace Tools
@@ -351,6 +352,25 @@ namespace Tools
public class NativeMethods
{
internal struct LASTINPUTINFO
{
public uint cbSize;
public uint dwTime;
}
[DllImport("User32.dll")]
private static extern bool GetLastInputInfo(ref LASTINPUTINFO plii);
public static TimeSpan GetIdleTime()
{
LASTINPUTINFO lastInPut = new LASTINPUTINFO();
lastInPut.cbSize = (uint)Marshal.SizeOf(lastInPut);
GetLastInputInfo(ref lastInPut);
return TimeSpan.FromMilliseconds((uint)Environment.TickCount - lastInPut.dwTime);
}
private const int WM_SYSCOMMAND = 0x0112;
private const int SC_MONITORPOWER = 0xF170;
private const int MONITOR_OFF = 2;