AutoHotkey Community

It is currently May 27th, 2012, 5:29 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 17 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: Hibernate() w/ Wakeup
PostPosted: November 3rd, 2009, 4:55 pm 
Offline
User avatar

Joined: December 26th, 2005, 4:40 pm
Posts: 8776
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


Last edited by SKAN on December 18th, 2009, 10:21 am, edited 2 times in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject: Let me be the first
PostPosted: November 4th, 2009, 2:24 am 
I can't beleive no one else has said this...


Thank you.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: November 4th, 2009, 10:07 am 
Offline
User avatar

Joined: December 26th, 2005, 4:40 pm
Posts: 8776
StreetRider@Large wrote:
Let me be the first


Gee.. :oops: Thanks.

Update: Code optimised/crunched from 13 lines to 10 lines.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 18th, 2009, 10:05 am 
Offline

Joined: November 21st, 2009, 11:06 am
Posts: 63
wow, awesome!
thanks


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 26th, 2009, 8:43 am 
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? :) Is this possible?


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: December 26th, 2009, 11:51 am 
Offline

Joined: December 23rd, 2009, 4:01 pm
Posts: 5
GuestAHK wrote:
When the computer resumes from hibernate, how do I have the monitor 'come alive' automatically? :) 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?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 11th, 2010, 8:24 pm 
Offline

Joined: December 31st, 2009, 4:57 pm
Posts: 20
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?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 11th, 2010, 8:31 pm 
Offline
User avatar

Joined: December 26th, 2005, 4:40 pm
Posts: 8776
whynotmore wrote:
does the entire line, Hibernate( A_Now, 30, "Minutes" ) go before the first line of the script?


Yes!


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 11th, 2010, 8:50 pm 
Offline

Joined: December 31st, 2009, 4:57 pm
Posts: 20
When it goes into hibernate, the computer immediatly wakes back up. Now, it even does it when we use shutdown > hibernate.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 11th, 2010, 9:09 pm 
Offline
User avatar

Joined: December 26th, 2005, 4:40 pm
Posts: 8776
What OS? If Win7, the problem could be USB mouse. See here
:arrow: I googled for Hibernate problem immediately wakes up


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 11th, 2010, 9:24 pm 
Offline

Joined: December 31st, 2009, 4:57 pm
Posts: 20
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?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 11th, 2010, 9:47 pm 
Offline
User avatar

Joined: December 26th, 2005, 4:40 pm
Posts: 8776
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.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 15th, 2010, 2:04 pm 
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


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: March 15th, 2010, 2:45 pm 
Offline
User avatar

Joined: December 26th, 2005, 4:40 pm
Posts: 8776
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 )


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 15th, 2010, 9:25 pm 
That's awesome - great work! 8)


Report this post
Top
  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 17 posts ]  Go to page 1, 2  Next

All times are UTC [ DST ]


Who is online

Users browsing this forum: Bing [Bot], Google Feedfetcher, sks, Stigg and 11 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group