每隔20分钟强制休息1分钟

class Program
    {
        private static Timer aTimer;

        static void Main(string[] args)
        {
            aTimer = new Timer(20 * 60 * 1000)
            {
                AutoReset = true,
                Enabled = true
            };
            aTimer.Elapsed += (o, e) =>
            {
                BlockInput(true);
                System.Threading.Thread.Sleep(1 * 60 * 1000);
                BlockInput(false);
                //LockWorkStation();
                //SendMessage((IntPtr)(-1), (uint)0x0112, (IntPtr)0xF170, (IntPtr)2);
            };
            Console.ReadKey();
        }

        //锁屏
        [DllImport("user32.dll")]
        public static extern bool LockWorkStation();

        //关屏
        [DllImport("user32.dll", CharSet = CharSet.Auto)]
        static extern IntPtr SendMessage(IntPtr hWnd, UInt32 Msg, IntPtr wParam, IntPtr lParam);

        //禁止鼠标键盘动做
        [return: MarshalAs(UnmanagedType.Bool)]
        [DllImport("user32.dll", CharSet = CharSet.Auto, ExactSpelling = true)]
        public static extern bool BlockInput([In, MarshalAs(UnmanagedType.Bool)] bool fBlockIt);
    }