Jump to content

(Solved) $WM_POWERBROADCAST Issue: Can not redeclare a constant


Recommended Posts

Hi brothers,

I was trying to run my program after wake from sleep and i found the code posted by @Jos :

#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
Global $PBT_APMRESUMEAUTOMATIC  =  0x0012

$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)
            MsgBox(0,"Hello Back", " You just woke up from Suspend")
        Case $wParam = $PBT_APMRESUMESTANDBY 
            ConsoleWrite(" You just woke up from Standby." & @LF)
            MsgBox(0,"Hello Back", " You just woke up from Standby")
        Case $wParam = $PBT_APMRESUMEAUTOMATIC
            ConsoleWrite(" You just woke up from ????." & @LF)
            MsgBox(0,"Hello Back", " You just woke up from ??????")
        Case Else
    EndSelect
EndFunc

after debug I always get this Error:
 

: ==> Can not redeclare a constant.:
Global $WM_POWERBROADCAST     = 536
Global ^ ERROR

 

Edited by abdulrahmanok
Link to comment
Share on other sites

  • Developers

I guess your question is why? 
Answer: It is already defined in the current version of the included files so simply comment it out in the script. :)

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

On 6/5/2017 at 11:01 PM, Jos said:

I guess your question is why? 
Answer: It is already defined in the current version of the included files so simply comment it out in the script. :)

Jos

Thank you , I didn't though it's easy like this because in  case of duplicate functions  debugger was mention to it.

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...