AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Hibernate() w/ Wakeup
Goto page 1, 2  Next
 
Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions
View previous topic :: View next topic  
Author Message
SKAN



Joined: 26 Dec 2005
Posts: 8688

PostPosted: Tue Nov 03, 2009 3:55 pm    Post subject: Hibernate() w/ Wakeup Reply with quote

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


Last edited by SKAN on Fri Dec 18, 2009 9:21 am; edited 2 times in total
Back to top
View user's profile Send private message Send e-mail
StreetRider@Large
Guest





PostPosted: Wed Nov 04, 2009 1:24 am    Post subject: Let me be the first Reply with quote

I can't beleive no one else has said this...


Thank you.
Back to top
SKAN



Joined: 26 Dec 2005
Posts: 8688

PostPosted: Wed Nov 04, 2009 9:07 am    Post subject: Reply with quote

StreetRider@Large wrote:
Let me be the first


Gee.. Embarassed Thanks.

Update: Code optimised/crunched from 13 lines to 10 lines.
Back to top
View user's profile Send private message Send e-mail
unknowingly



Joined: 21 Nov 2009
Posts: 63

PostPosted: Fri Dec 18, 2009 9:05 am    Post subject: Reply with quote

wow, awesome!
thanks
Back to top
View user's profile Send private message
GuestAHK
Guest





PostPosted: Sat Dec 26, 2009 7:43 am    Post subject: Reply with quote

SKAN, ... wow this is amazing and just what I was looking for! May I ask how, if I can have the function to do one more step?



When the computer resumes from hibernate, how do I have the monitor 'come alive' automatically? Smile Is this possible?
Back to top
foxer



Joined: 23 Dec 2009
Posts: 5

PostPosted: Sat Dec 26, 2009 10:51 am    Post subject: Reply with quote

GuestAHK wrote:
When the computer resumes from hibernate, how do I have the monitor 'come alive' automatically? Smile Is this possible?


This is a good question; I am also looking for a way to do this. I usually make my computer hibernate by the Windows menu, but I need to run a task (namely, restart ad hoc Wi-Fi, as mentioned in this French article), either by Windows itself or by AutoHotKey when the computer restarts from hibernate.
Any ideas?
Back to top
View user's profile Send private message
whynotmore



Joined: 31 Dec 2009
Posts: 20

PostPosted: Thu Mar 11, 2010 7:24 pm    Post subject: Reply with quote

We cannot seem to get this script to work. in the usage examples, are you saying to make T="" be T="A_NOW" ? or does the entire line, Hibernate( A_Now, 30, "Minutes" ) go before the first line of the script?
Back to top
View user's profile Send private message
SKAN



Joined: 26 Dec 2005
Posts: 8688

PostPosted: Thu Mar 11, 2010 7:31 pm    Post subject: Reply with quote

whynotmore wrote:
does the entire line, Hibernate( A_Now, 30, "Minutes" ) go before the first line of the script?


Yes!
Back to top
View user's profile Send private message Send e-mail
whynotmore



Joined: 31 Dec 2009
Posts: 20

PostPosted: Thu Mar 11, 2010 7:50 pm    Post subject: Reply with quote

When it goes into hibernate, the computer immediatly wakes back up. Now, it even does it when we use shutdown > hibernate.
Back to top
View user's profile Send private message
SKAN



Joined: 26 Dec 2005
Posts: 8688

PostPosted: Thu Mar 11, 2010 8:09 pm    Post subject: Reply with quote

What OS? If Win7, the problem could be USB mouse. See here
Arrow I googled for Hibernate problem immediately wakes up
Back to top
View user's profile Send private message Send e-mail
whynotmore



Joined: 31 Dec 2009
Posts: 20

PostPosted: Thu Mar 11, 2010 8:24 pm    Post subject: Reply with quote

that is very strange. we are running windows XP sp3.
Where is the CreateWaitTimer, SetWaitTimer, LocalFileTimeToFileTime, and WaitForSingleObject DLL's stored? The only one that I can find is the PowrProf.dll Which looks like it sends it into hibernate. Are those DLLs created by the script?
Back to top
View user's profile Send private message
SKAN



Joined: 26 Dec 2005
Posts: 8688

PostPosted: Thu Mar 11, 2010 8:47 pm    Post subject: Reply with quote

whynotmore wrote:
we are running windows XP sp3.


Same here.

whynotmore wrote:
Where is the CreateWaitTimer, SetWaitTimer, LocalFileTimeToFileTime, and WaitForSingleObject DLL's stored?


Them are available in Kernel32.dll which is loaded by windows on boot.
The functions in Kernel32.dll are readily available.. whereas for PowrProf.dll, AHK will load the DLL - call the function and unload it.
Back to top
View user's profile Send private message Send e-mail
ddk__
Guest





PostPosted: Mon Mar 15, 2010 1:04 pm    Post subject: Reply with quote

Hi SKAN. Scripts works awesome after quick testing =)!
How does those timestamps work? Can I set an exact time? Like 16:00 o'clock or something? : )

Thanks, ddk
Back to top
SKAN



Joined: 26 Dec 2005
Posts: 8688

PostPosted: Mon Mar 15, 2010 1:45 pm    Post subject: Reply with quote

ddk__ wrote:
How does those timestamps work?


The first parameter T should be a valid time stamp.
If you pass null or an empty variable, AHK will presume current date-time.

The second parameter O is offset. The time Value that will be added to T

The third parameter is U is timeUnits which will decide whether O is Seconds, Minutes, Hours, or Days

Please refer AHK Doc for EnvAdd command to understand the first line of my Function.

ddk__ wrote:
Can I set an exact time? Like 16:00 o'clock or something? : )


Yes!

You may call the function like: Hibernate( 201003151600 ) or may be,

Code:
WakeupTime := A_YYYY A_MM A_DD "1600"
Hibernate( WakeupTime )
Back to top
View user's profile Send private message Send e-mail
ddk__
Guest





PostPosted: Mon Mar 15, 2010 8:25 pm    Post subject: Reply with quote

That's awesome - great work! Cool
Back to top
Display posts from previous:   
Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions All times are GMT
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group