mirror of
https://github.com/jkocon/g-helper.git
synced 2026-02-23 13:00:52 +01:00
Tweaks and fixes
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user