1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
| Dim Wrap, pAddr
Dim CaptionWnd
Dim intButton
Const WM_CLOSE = &H10
Set WshShell = WScript.CreateObject("WScript.Shell")
Set Wrap = CreateObject("DynamicWrapperX")
Set pRef = GetRef("TimerProc")
Wrap.Register "user32.dll", "FindWindowA", "i=ls", "r=l"
Wrap.Register "user32.dll", "FindWindowExA", "i=llsl", "r=l"
Wrap.Register "user32.dll", "SetTimer", "i=llll", "r=l"
Wrap.Register "user32.dll", "KillTimer", "i=ll", "r=l"
Wrap.Register "user32.dll", "SendMessageA", "i=llll", "r=l"
pAddr = Wrap.RegisterCallback(pRef, "i=llll", "r=l")
Function PopupEx(strText, nSecondsToWait, strTitle, nType)
CaptionWnd = strTitle
'le timeout est au minimum et le timer ne sera désactivé que lorsque le popup aura été créé
Wrap.SetTimer 0, 0, 10, pAddr
PopupEx = WshShell.Popup(strText, nSecondsToWait, strTitle, nType)
End Function
Sub TimerProc(hWnd, uMsg, idEvent, dwTime)
Dim myHwnd
myHwnd = Wrap.FindWindowExA(Wrap.FindWindowA(0, CaptionWnd), 0, "Button", 0)
If myHwnd <> 0 Then Wrap.KillTimer 0, idEvent 'le timer est devenu inutile donc destruction
Wrap.SendMessageA myHwnd, WM_CLOSE, 0, 0
End Sub
intButton = PopupEx("Hello world", 4, "Greeting from omen999",0) |
Partager