예제 #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());
        }
    }