Search the Community
Showing results for tags 'standby'.
-
Jos suggested in one of the themes the following code: #include <WindowsConstants.au3> #include <GUIConstants.au3> #include <Date.au3> Global $PBT_APMSUSPEND = 0x0004 Global $PBT_APMRESUMESUSPEND = 0x0007 Global $PBT_APMSTANDBY = 0x0005 Global $PBT_APMRESUMESTANDBY = 0x0008 Dim $hGUI = GUICreate("Test", 100, 100,1,1) ;You need to work without this line. GUIRegisterMsg($WM_MOUSEWHEEL, "Standby") Func Standby($hWnd, $Msg, $wParam, $lParam) ConsoleWrite(_NowTime() & ": " & $wParam & @LF) Select Case $wParam = $PBT_APMSUSPEND ConsoleWrite(" You going into Suspend." & @LF) Case $wParam = $PBT_APMRESUMESUSPEND ConsoleWrite(" You just woke up from Suspend." & @LF) Case $wParam = $PBT_APMSTANDBY ConsoleWrite(" You are going into Standby." & @LF) Case $wParam = $PBT_APMRESUMESTANDBY ConsoleWrite(" You just woke up from Standby." & @LF) Case Else EndSelect EndFunc My application does not use any windows. It has only a menu in the tray. Tell me, who knows how to make this code work in my case. Thank you!
-
I have a light bulb which I can turn on and off using UDP commands (I already have that working in AutoIt). What I would like to do is run a script before the computer goes to sleep to turn it off, and after it resumes to turn it on. I've already got the latter working, but not the former. I tried Task Scheduler with the kernel power log, but the command doesn't get executed until the computer resumes from sleep. I've tried some things using WM_POWERBROADCAST, but so far I haven't got that to work either. Here's what I've got so far: Global Const $WM_POWERBROADCAST = 0x218 Global Const $PBT_APMSUSPEND = 0x4 Global Const $PBT_APMRESUMEAUTOMATIC = 0x12 While 1 Sleep(100) WEnd GUICreate("Event Receiver") GUIRegisterMsg($WM_POWERBROADCAST,"MY_WM_POWERBROADCAST") Func MY_WM_POWERBROADCAST($hWnd, $uMsg, $wParam, $lParam) Switch $wParam Case $PBT_APMSUSPEND MsgBox(0,"PBT_APMSUSPEND","PBT_APMSUSPEND"&@HOUR&@MIN&@SEC) Case $PBT_APMRESUMEAUTOMATIC MsgBox(0,"PBT_APMSUSPEND","PBT_APMRESUMEAUTOMATIC"&@HOUR&@MIN&@SEC) EndSwitch EndFunc Does anyone know how to make this work?