Jump to content

How to prevent a PC going into hybernate


Noob
 Share

Recommended Posts

  • 2 years later...

I've been using the following code to prevent Windows XP systems from going into stand-by or even the screen-saver from kicking in - has really solved a problem for me.

However, this doesn't seem to work on Vista or Win7 systems. Are there different locations that need to be referenced or is the the kernel21.dll no longer the one that controls this?

I would appreciate any advice.

Try this...

AdlibEnable( "NoSleep", 50 * 1000 ); reset the standy-timer every 50 seconds

Func NoSleep(); see the description of the SetThreadExecutionState function of kernel32.dll at http://msdn2.microsoft.com/en-us/library/aa373208.aspx
    Local Const $ES_DISPLAY_REQUIRED = 0x00000002; use this to zero the display's idle timer
    Local Const $ES_SYSTEM_REQUIRED  = 0x00000001; use this to zero the system's  idle timer
    Local Const $ES_CONTINUOUS     = 0x80000000; add this to the other flag(s) to keep the display or system on until another call to SetThreadExecutionState with $ES_CONTINUOUS without the other flag(s)
    DllCall( "kernel32.dll", "int", "SetThreadExecutionState", "int", $ES_SYSTEM_REQUIRED )
EndFunc

Link to comment
Share on other sites

  • 6 months later...
  • 2 months later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...