[color=red]Hibernate([/color] T="", O=0, U="H" [color=red])[/color] { ; [color=indigo]by SKAN[/color] www.autohotkey.com/forum/viewtopic.php?t=50733 T += %O%,%U% EnvSub, T, 16010101, S VarSetCapacity(FT,8), DllCall( "[color=#D62A00]LocalFileTimeToFileTime[/color]", Int64P,T:=T*10000000,UInt,&FT ) If hTmr := DllCall( "[color=#D62A00]CreateWaitableTimer[/color]", UInt,0, UInt,0, UInt,0 ) If DllCall( "[color=#D62A00]SetWaitableTimer[/color]", UInt,hTmr, UInt,&FT, UInt,1000, Int,0, Int,0, UInt,1 ) If DllCall( "[color=#D62A00]PowrProf\SetSuspendState[/color]", UInt,1, UInt,0, UInt,0 ) DllCall( "[color=#D62A00]WaitForSingleObject[/color]", UInt,hTmr,Int,-1 ), DllCall( "[color=#D62A00]CloseHandle[/color]",UInt,hTmr ) Return A_LastError }
Usage Examples:
Hibernate( 20100101 ) ; until a future Timestamp ( New Year )
Hibernate( A_Now, 600, "Seconds" )
Hibernate( A_Now, 30, "Minutes" )
Hibernate( A_Now, 2, "Hours" ) or Hibernate( Null, 2 )
Hibernate( A_Now, 7, "Days" )
Credit: Thanks to Boskoop's Wake-up-timer/ Scheduler-Function