dcsimg
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: Prevent screen saver from activating

  1. #1
    Join Date
    Nov 2011
    Posts
    72

    Prevent screen saver from activating

    Windows 10, visual Studio, c++

    There are some times when I want to prevent the screen saver for activating when there has been no input from the user. But not all the time.
    What is the most simple way I can generate some data in an app and make the computer think someone pecked a key or moved the mouse?

  2. #2
    Join Date
    Jun 2002
    Location
    Stockholm, Sweden
    Posts
    1,641

    Re: Prevent screen saver from activating

    This worked in win 7 and earlier, and I see no reason why it should not work in Win 10:
    Code:
    		int timeout;
    		if(SystemParametersInfo(SPI_GETSCREENSAVETIMEOUT, 0, &timeout, 0))
    			SystemParametersInfo(SPI_SETSCREENSAVETIMEOUT, timeout, NULL, 0);
    You need to call it periodically, once every 30 seconds or so.
    Nobody cares how it works as long as it works

  3. #3
    Join Date
    Nov 2003
    Posts
    1,902

    Re: Prevent screen saver from activating

    You may want to use SetThreadExecutionState in addition to the above - to prevent sleeping.

    gg

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width




On-Demand Webinars (sponsored)