Jump to content
Sign in to follow this  
BillLuvsU

Standbye detection

Recommended Posts

BillLuvsU

Does anybody know of a way to detect when a script comes out of standbye? I'm trying to make a security system for my laptop and I always just put it in standbye instead of turning it off, so that will be kind of inportant. An explanation of how standbye works, or exactly what is might help me to figure it out too. Thanks in advance!


[center][/center]Working on the next big thing.Currently Playing: Halo 4, League of LegendsXBL GT: iRememberYhslaw

Share this post


Link to post
Share on other sites
Jos

Give this a try:

#include <GUIConstants.au3>
#include <date.au3>
;~ #define PBT_APMQUERYSUSPEND           0x0000
;~ #define PBT_APMQUERYSTANDBY           0x0001
;~ #define PBT_APMQUERYSUSPENDFAILED       0x0002
;~ #define PBT_APMQUERYSTANDBYFAILED       0x0003
;~ #define PBT_APMSUSPEND                 0x0004
;~ #define PBT_APMSTANDBY                 0x0005
;~ #define PBT_APMRESUMECRITICAL           0x0006
;~ #define PBT_APMRESUMESUSPEND         0x0007
;~ #define PBT_APMRESUMESTANDBY         0x0008
;~ #define PBTF_APMRESUMEFROMFAILURE       0x00000001
;~ #define PBT_APMBATTERYLOW               0x0009
;~ #define PBT_APMPOWERSTATUSCHANGE     0x000A
;~ #define PBT_APMOEMEVENT               0x000B
;~ #define PBT_APMRESUMEAUTOMATIC         0x0012
Global $WM_POWERBROADCAST     = 536
Global $PBT_APMRESUMESUSPEND  =  0x0007
Global $PBT_APMRESUMESTANDBY  =  0x0008

$hGUI      = GUICreate("Test", 100, 100,1,1)
GUIRegisterMsg($WM_POWERBROADCAST, "Standby")
;~ GUISetState()
While 1
    Sleep(10)
;~ $GUIMsg = GUIGetMsg()
;~   Switch $GUIMsg
;~       Case $GUI_EVENT_CLOSE
;~           ExitLoop
;~   EndSwitch
WEnd
;
Exit
;
Func Standby($hWnd, $Msg, $wParam, $lParam)
    ConsoleWrite(_NowTime() & ": " & $wParam & @LF)
    Select
        Case $wParam = $PBT_APMRESUMESUSPEND 
            ConsoleWrite(" You just woke up from Suspend." & @LF)
        Case $wParam = $PBT_APMRESUMESTANDBY 
            ConsoleWrite(" You just woke up from Standby." & @LF)
        Case Else
    EndSelect
EndFunc
Edited by JdeB

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
BillLuvsU

Thanks alot JdeB, that will help out alot! Always in admiration of your knowledge ;P


[center][/center]Working on the next big thing.Currently Playing: Halo 4, League of LegendsXBL GT: iRememberYhslaw

Share this post


Link to post
Share on other sites
matrix200

Hey I have a similar problem with my script where I need to detect going to hibernate and back to normal operation of a script.

Is there a code for Hibernate and Resume from Hibernate as well or does it use the Suspend event?

Share this post


Link to post
Share on other sites
Jos

Hey I have a similar problem with my script where I need to detect going to hibernate and back to normal operation of a script.

Is there a code for Hibernate and Resume from Hibernate as well or does it use the Suspend event?

Have you tried to run the script and then go into Hibernation ?

You will see which messages are triggered in the SciTE outputpane :)

Edited by Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
Glyph

Hey I have a similar problem with my script where I need to detect going to hibernate and back to normal operation of a script.

Is there a code for Hibernate and Resume from Hibernate as well or does it use the Suspend event?

Pro Hijacker.

I couldn't resist!


tolle indicium

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×