WPF 检测输入状态

        [DllImport("user32.dll")]
static extern bool GetLastInputInfo(ref LASTINPUTINFO plii); public static long GetIdleTick()
{
LASTINPUTINFO lastInputInfo = new LASTINPUTINFO();
lastInputInfo.cbSize = Marshal.SizeOf(lastInputInfo);
if (!GetLastInputInfo(ref lastInputInfo)) return ;
return Environment.TickCount - (long)lastInputInfo.dwTime;
} [StructLayout(LayoutKind.Sequential)]
private struct LASTINPUTINFO
{
[MarshalAs(UnmanagedType.U4)]
public int cbSize;
[MarshalAs(UnmanagedType.U4)]
public uint dwTime;
}
上一篇:es6 super关键字


下一篇:STM32CubeMX HAL库串口+DMA数据发送不定长度数据接收