Jump to content

Standbye detection


BillLuvsU
 Share

Recommended Posts

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

Link to comment
Share on other sites

  • Developers

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 etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

  • 3 months later...
  • Developers

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 etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

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

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...