apstanto Posted September 10, 2010 Share Posted September 10, 2010 I've been using bastel123's code for putting a laptop into Hibernate (or standby), and then having it resume automatically. I'd like some insight into how the code works, because I'm having trouble with it on XP and not other platforms. What is different about XP that would cause:1) The timer to not work correctly. It works the first iteration, but after that it stays in the powersave mode for only one second and then resumes.2) Sometimes it gets stuck in hibernate and never resumes.I don't have any of these problems with Windows 7 or Vista. Whats different about XP? Thanks in advance! Link to comment Share on other sites More sharing options...
seandisanti Posted September 13, 2010 Share Posted September 13, 2010 it looks like the issue is in your implementation rather than his code, most likely you're not recalling the SetWakeUpTime() function on subsequent iterations, so it's using the same wake time which will have already passed Link to comment Share on other sites More sharing options...
apstanto Posted September 13, 2010 Author Share Posted September 13, 2010 it looks like the issue is in your implementation rather than his code, most likely you're not recalling the SetWakeUpTime() function on subsequent iterations, so it's using the same wake time which will have already passedThanks for the reply! I do a SetWakeUpTime() for each new iteration. I know the implementation is correct, because it works in Win7 and Vista. Unless there is something different/special I need to do for XP!?!? Link to comment Share on other sites More sharing options...
seandisanti Posted September 13, 2010 Share Posted September 13, 2010 Thanks for the reply! I do a SetWakeUpTime() for each new iteration. I know the implementation is correct, because it works in Win7 and Vista. Unless there is something different/special I need to do for XP!?!?without seeing the code, i can't tell you why it's not working Link to comment Share on other sites More sharing options...
apstanto Posted September 13, 2010 Author Share Posted September 13, 2010 SetWakeUpTime() and SetSuspend() are the same as bastel123's code. And like I said, this works perfectly in Windows 7 and Vista. $MinutesToWake = 1. I call the following in a loop:expandcollapse popup#cs ********************************************************************************************************* Function Name: PowerSave Author: Andrew Stanton - apstanto@gmail.com Description: Sends the system into the sleep state for the amount of time spcified in the .ini file Requirement(s): PowrProf.dll, kernel32.dll (note: these dll files are found in C:\Windows\System32 folder of all Windows versions tested.) Input: none Return: 1 on success 0 on failure #ce ********************************************************************************************************* Func PowerSave() Trace("PowerSave", $TRACE_FUNC_START) ; Show Standby message $button = MsgBox(1, "Host Automation Tester", "Going to " & $State & " for " & $MinutesToWake & " minute(s) ...", 2) If $button = 2 Then Return 0 EndIf ; Set wakeup time If Not SetWakeUpTime(@HOUR, @MIN + $MinutesToWake) Then If not @extended = 0 Then Trace("Unknown error occured in SetWakeUpTime()!!! @error = " & @extended , $TRACE_ERROR) EndIf EndIf ; Power save If $SleepState = $HIBERNATE Then Trace ("Hibernate at " & @HOUR&":"&@MIN&":"&@SEC&@CRLF, $TRACE_MSG) SetSuspend(True) ElseIf $SleepState = $STANDBY Then Trace ("Standby at " & @HOUR&":"&@MIN&":"&@SEC&@CRLF, $TRACE_MSG) SetSuspend(False) Else Trace("Unknown Sleep State: " & $SleepState, $TRACE_ERROR) Trace("PowerSave", $TRACE_FUNC_END) Return 0 EndIf ; Resume Trace ("Resumed at " & @HOUR & ":" & @MIN & ":" & @SEC & @CRLF, $TRACE_MSG) _Monitor_ON() ; wait for applications to start sleep ($APP_DELAY_SHORT * 1000) If @error = 0 Then Trace("PowerSave", $TRACE_FUNC_END) Return 1 Else Trace ("**** Failed to powersave!****", $TRACE_MSG) MsgBox(1, "Powersave Error", "Failed to powersave. " & @LF & @LF & _ "Error Code: " & @error & @LF & " Key: " & _ "1 unable to use the DLL file" & @LF & _ "2 unknown return type" & @LF & _ "3 function not found in the DLL file" & @LF & _ "4 bad number of parameters." & @LF & @LF & _ "See AutoIt DllCall() for more informationl.") Trace("PowerSave", $TRACE_FUNC_END) Return 0 EndIf EndFuncI hope that's enough to see the general picture! Link to comment Share on other sites More sharing options...
apstanto Posted September 15, 2010 Author Share Posted September 15, 2010 Any ideas? Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now