コード例 #1
0
ファイル: Form1.cs プロジェクト: akinohana/BuMoyu
            public bool IsWorkingOnPC()
            {
                WinAPI.LASTINPUTINFO lastInputInfo = new WinAPI.LASTINPUTINFO();
                lastInputInfo.cbSize = (uint)Marshal.SizeOf(lastInputInfo);
                WinAPI.GetLastInputInfo(ref lastInputInfo);

                var idieTime = TimeSpan.FromMilliseconds(Environment.TickCount - lastInputInfo.dwTime);

                if (idieTime.TotalSeconds > moyuConfig.MaxNoActionTime)
                {
                    return(false);
                }

                return(true);
            }
コード例 #2
0
    public static int GetLastInputSeconds()
    {
        var plii = new WinAPI.LASTINPUTINFO();

        plii.cbSize = (uint)Marshal.SizeOf(plii);
        if (WinAPI.GetLastInputInfo(ref plii))
        {
            var lastInputTime = TimeSpan.FromMilliseconds(Environment.TickCount - plii.dwTime).TotalSeconds;
            return((int)lastInputTime);
        }

        else
        {
            throw new System.ComponentModel.Win32Exception(Marshal.GetLastWin32Error());
        }
    }