Sign in to follow this  
Followers 0
sir

problem with hibernate

3 posts in this topic

how to let start program just after wake up from hibernate?

Share this post


Link to post
Share on other sites



#include <GUIConstants.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

$hGUI       = GUICreate("Test", 100, 100,1,1)
GUIRegisterMsg($WM_POWERBROADCAST, "Standby")
GUISetState()
While 1
    $GUIMsg = GUIGetMsg()
    Switch $GUIMsg
        Case $GUI_EVENT_CLOSE
            ExitLoop
    EndSwitch
WEnd
;
Exit
;
Func Standby($hWnd, $Msg, $wParam, $lParam)
    If $wParam = $PBT_APMRESUMESUSPEND Then
        MsgBox(0,"Hello Back", " You just woke up")
    EndIf
EndFunc


Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

Hi,

In the help file they say

Warning: blocking of running user functions which executes window messages with commands such like "Msgbox()" can lead to unexpected behavior, the return to the system should be as fast as possible !!!

so it's better to put the msgbox in the main loop like this :

#include <GUIConstants.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 $SortieDeVeille=0

$hGUI      = GUICreate("Test", 100, 100,1,1)
GUIRegisterMsg($WM_POWERBROADCAST, "Standby")
GUISetState()
While 1
    if $SortieDeVeille=1 Then
        $SortieDeVeille=0
        MsgBox(0,"Réveil", "Vous étiez en veille !")
    EndIf
    $GUIMsg = GUIGetMsg()
    Switch $GUIMsg
        Case $GUI_EVENT_CLOSE
            ExitLoop
    EndSwitch
WEnd
;
Exit
;
Func Standby($hWnd, $Msg, $wParam, $lParam)
    If $wParam = $PBT_APMRESUMESUSPEND Then
        $SortieDeVeille=1
    EndIf
EndFunc

hope this help

:lmao:

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  
Followers 0