Results 1 to 3 of 3

Thread: Prevent Windows from entering in hibernate/sleep mode

  1. #1
    Join Date
    Nov 2007
    Location
    Italy
    Posts
    694
    Thanks
    59
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Prevent Windows from entering in hibernate/sleep mode

    I have a Qt application that periodically performs some checks using a video camera (it takes and processes an image every second). I need Windows to be active without going into hibernation nor sleep mode as long as the application is running and to achieve it I have added the following code fragment in the main.cpp file of my application

    Qt Code:
    1. // ... previous code omitted
    2. // From documentation, it should inform the o.s. that the app is in use preventing it to hibernate or sleep
    3. SetThreadExecutionState(ES_CONTINUOUS | ES_DISPLAY_REQUIRED | ES_SYSTEM_REQUIRED | ES_AWAYMODE_REQUIRED);
    4.  
    5. // Execute the main application
    6. LoginDialog loginDialog(!appMode);
    7. int result = loginDialog.proceed() ? application.exec() : 0;
    8.  
    9. // Restore to the previous state when the app closes
    10. SetThreadExecutionState(ES_CONTINUOUS);
    11.  
    12. return result;
    To copy to clipboard, switch view to plain text mode 

    Unfortunately this approach is not giving the desired effects and after some time it hibernates and I don't understand why. Unfortunately I can't run the program with administrator privileges and this could be the cause but I'm not sure. I would like some help in solving my problem.
    Franco Amato

  2. #2
    Join Date
    Nov 2024
    Posts
    2
    Qt products
    Qt5

    Default Re: Prevent Windows from entering in hibernate/sleep mode

    Go to Control Panel > Power Options and modify sleep/hibernate times.

  3. #3
    Join Date
    Mar 2008
    Location
    Kraków, Poland
    Posts
    1,537
    Thanked 284 Times in 279 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Prevent Windows from entering in hibernate/sleep mode


Similar Threads

  1. Prevent switching between windows
    By maratk1n in forum Newbie
    Replies: 6
    Last Post: 14th August 2017, 20:20
  2. Hibernate port
    By ckoplay in forum General Programming
    Replies: 4
    Last Post: 23rd March 2015, 10:29
  3. Replies: 0
    Last Post: 23rd November 2011, 19:56
  4. Standby / hibernate system events
    By rensdenobel in forum Qt Programming
    Replies: 0
    Last Post: 13th October 2008, 18:39
  5. sleep - sleeps, but not when I want it to sleep
    By nongentesimus in forum Newbie
    Replies: 2
    Last Post: 2nd March 2006, 15:43

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.