Use:
OnResume( Label [, Delay ] )
where
Label = Subroutine to run
Delay = delay in ms
Code: [Select all] [Expand] [Download] (OnResume.ahk)GeSHi © Codebox Plus
OnResume(Label,Delay=200,Msg="") {
static Init, Label_, Delay_
If !Init ;first time called
{
DllCall("RegisterSuspendResumeNotification", "ptr", A_ScriptHwnd, "uint", 0)
DllCall( "Wtsapi32.dll\WTSRegisterSessionNotification", "uint", A_ScriptHwnd, "uint", 1 )
OnMessage(0x218, "OnResume") ;WM_POWERBROADCAST
OnMessage(0x2B1, "OnResume") ;WM_WTSSESSION_CHANGE
Label_ := Label
Delay_ := Delay
}
Init := 1
If !IsLabel(Label_)
Return
If (Msg = 0x218)
If (Label=0x7) OR (Label=0x8) OR (Label=0x18) ; PBT_APMRESUMESUSPEND=0x7, PBT_APMRESUMESTANDBY=0x8, PBT_APMRESUMEAUTOMATIC=0x18
SetTimer, %Label_%, -%Delay_%
If (Msg = 0x2B1)
If (Label=0x8) OR (Label=0x5) ; UNLOCK=0x8,LOGON=0x5
SetTimer, %Label_%, -%Delay_%
}
feedback appreciated
enjoy
- gwarble