防止自动锁屏代码

  class Work

    {

        [DllImport("user32.dll")]

        static extern void mouse_event(MouseEventFlag flags, int dx, int dy, uint data, UIntPtr extraInfo);



        enum MouseEventFlag : uint

        {

            Move = 0x0001,

        }



        public static void DoWork()

        {

            while (true)

            {

                mouse_event(MouseEventFlag.Move, 0, 0, 0, UIntPtr.Zero);

                Thread.Sleep(480000);

            }



        }

    }

 

你可能感兴趣的:(代码)