Code:
Hibernate( T="", O=0, U="H" ) { ; by SKAN www.autohotkey.com/forum/viewtopic.php?t=50733
T += %O%,%U%
EnvSub, T, 16010101, S
VarSetCapacity(FT,8), DllCall( "LocalFileTimeToFileTime", Int64P,T:=T*10000000,UInt,&FT )
If hTmr := DllCall( "CreateWaitableTimer", UInt,0, UInt,0, UInt,0 )
If DllCall( "SetWaitableTimer", UInt,hTmr, UInt,&FT, UInt,1000, Int,0, Int,0, UInt,1 )
If DllCall( "PowrProf\SetSuspendState", UInt,1, UInt,0, UInt,0 )
DllCall( "WaitForSingleObject", UInt,hTmr,Int,-1 ), DllCall( "CloseHandle",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
_________________
URLGet - Internet Explorer based Downloader
StartEx - Portable Shortcut Link