2013-10-29 7 views
0

시스템이 종료되거나 재부팅 될 때 AutoIt 디스플레이에 msgbox를 표시하려고합니다. 나는 이것을 시도했다 :AutoIt - 시스템 종료/재부팅

#include <WindowsConstants.au3> 

$hGUI = GuiCreate("") ; Create a GUI and don't show it 
GuiRegisterMsg($WM_ENDSESSION, "WM_ENDSESSION") 

; Do stuff here... 
While 1 ; Loop does nothing 
    Sleep(100) 
WEnd 

Func WM_ENDSESSION($hWnd, $Msg, $wParam, $lParam) 
    MsgBox(0,"SystemShutdown", @HOUR & ":" & @MIN & ":" & @SEC & @TAB & "WM_ENDSESSION: " & $hWnd & ", " & $Msg & ", " & $wParam & ", " & $lParam & @CRLF) 
EndFunc 

그러나 그것은 작동하지 않을 것이다?

답변

2

이 시도 :

#include <WindowsConstants.au3> 
#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 $PBT_APMSUSPEND = 0x0004 
Global $PBT_APMRESUMESUSPEND = 0x0007 
Global $PBT_APMSTANDBY = 0x0005 
Global $PBT_APMRESUMESTANDBY = 0x0008 

$hGUI = GUICreate("Test", 100, 100, 1, 1) 
GUIRegisterMsg($WM_POWERBROADCAST, "Standby") 
GUIRegisterMsg($WM_QUERYENDSESSION, "_Shutdown") 
;~ 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_APMSUSPEND 
      ConsoleWrite(" You going into Suspend." & @LF) 
     Case $wParam = $PBT_APMRESUMESUSPEND 
      ConsoleWrite(" You just woke up from Suspend." & @LF) 
     Case $wParam = $PBT_APMRESUMESTANDBY 
      ConsoleWrite(" You are going into Standby." & @LF) 
     Case $wParam = $PBT_APMRESUMESTANDBY 
      ConsoleWrite(" You just woke up from Standby." & @LF) 
      ;MsgBox(0,"Hello Back", " You just woke up from Standby") 
     Case Else 
    EndSelect 
EndFunc ;==>Standby 

Func _Shutdown() 
    MsgBox(16, 'SHUTDOWN', ' oh oh shutting down ... ') 
EndFunc ;==>_Shutdown