How long since coming out of standby?
How long since coming out of standby?
My app needs to know how long it's been since my PC came out of standby. Any ideas on how to test for that? Thanks.
- netmaestro
- PureBasic Bullfrog
- Posts: 8433
- Joined: Wed Jul 06, 2005 5:42 am
- Location: Fort Nelson, BC, Canada
Re: How long since coming out of standby?
This page looks like it would serve. You could start counting a timer when your app receives WM_POWERBROADCAST with wParam = PBT_APMRESUMEAUTOMATIC and you'll always know how long since the last resume (sounds good on paper anyway) https://msdn.microsoft.com/en-us/librar ... s.85).aspx
BERESHEIT
Re: How long since coming out of standby?
Thanks netmaestro! I was able to do it like this:
Code: Select all
Global awake
Procedure Callback(hWnd,Message,wParam,lParam)
result=#PB_ProcessPureBasicEvents
If Message=#WM_POWERBROADCAST
Select wParam
Case #PBT_APMRESUMESUSPEND
awake=Date()
Case #PBT_APMSUSPEND
awake=0
EndSelect
EndIf
ProcedureReturn result
EndProcedure
OpenWindow(0,200,200,200,100,"Time awake",#PB_Window_SystemMenu)
TextGadget(0,10,10,180,180,"")
SetWindowCallback(@Callback(),0)
Repeat
ev=WindowEvent()
If ev=0
Sleep_(500)
If awake
SetGadgetText(0,Str(Date()-awake))
EndIf
EndIf
Until ev=#PB_Event_CloseWindow
Re: How long since coming out of standby?
Thanks also to PureLust for this thread: http://www.purebasic.fr/english/viewtop ... 13&t=44388