 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
SKAN
Joined: 26 Dec 2005 Posts: 8688
|
Posted: Tue Nov 03, 2009 3:55 pm Post subject: Hibernate() w/ Wakeup |
|
|
| 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 |
|
 |
StreetRider@Large Guest
|
Posted: Wed Nov 04, 2009 1:24 am Post subject: Let me be the first |
|
|
I can't beleive no one else has said this...
Thank you. |
|
| Back to top |
|
 |
SKAN
Joined: 26 Dec 2005 Posts: 8688
|
Posted: Wed Nov 04, 2009 9:07 am Post subject: |
|
|
| StreetRider@Large wrote: | | Let me be the first |
Gee.. Thanks.
Update: Code optimised/crunched from 13 lines to 10 lines. |
|
| Back to top |
|
 |
unknowingly
Joined: 21 Nov 2009 Posts: 63
|
Posted: Fri Dec 18, 2009 9:05 am Post subject: |
|
|
wow, awesome!
thanks |
|
| Back to top |
|
 |
GuestAHK Guest
|
Posted: Sat Dec 26, 2009 7:43 am Post subject: |
|
|
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? |
|
| Back to top |
|
 |
foxer
Joined: 23 Dec 2009 Posts: 5
|
Posted: Sat Dec 26, 2009 10:51 am Post subject: |
|
|
| 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? |
|
| Back to top |
|
 |
whynotmore
Joined: 31 Dec 2009 Posts: 20
|
Posted: Thu Mar 11, 2010 7:24 pm Post subject: |
|
|
| 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 |
|
 |
SKAN
Joined: 26 Dec 2005 Posts: 8688
|
Posted: Thu Mar 11, 2010 7:31 pm Post subject: |
|
|
| whynotmore wrote: | | does the entire line, Hibernate( A_Now, 30, "Minutes" ) go before the first line of the script? |
Yes! |
|
| Back to top |
|
 |
whynotmore
Joined: 31 Dec 2009 Posts: 20
|
Posted: Thu Mar 11, 2010 7:50 pm Post subject: |
|
|
| When it goes into hibernate, the computer immediatly wakes back up. Now, it even does it when we use shutdown > hibernate. |
|
| Back to top |
|
 |
SKAN
Joined: 26 Dec 2005 Posts: 8688
|
|
| Back to top |
|
 |
whynotmore
Joined: 31 Dec 2009 Posts: 20
|
Posted: Thu Mar 11, 2010 8:24 pm Post subject: |
|
|
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 |
|
 |
SKAN
Joined: 26 Dec 2005 Posts: 8688
|
Posted: Thu Mar 11, 2010 8:47 pm Post subject: |
|
|
| 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 |
|
 |
ddk__ Guest
|
Posted: Mon Mar 15, 2010 1:04 pm Post subject: |
|
|
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
|
Posted: Mon Mar 15, 2010 1:45 pm Post subject: |
|
|
| 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 |
|
 |
ddk__ Guest
|
Posted: Mon Mar 15, 2010 8:25 pm Post subject: |
|
|
That's awesome - great work!  |
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|