I know this is really ugly, but I encourage that this be modified so we may all learn how to do it the proper way!

My excuses for bad code:
I've been up all night and haven't had my coffee yet!
The cat made me do it.
The dog ate my homework.
etc.
Code: Select all
;Global Title.s,Timeout,hWnd
Global *Timer=AllocateMemory(255)
Prototype ProtoFindWindow(Class.l,Title.s)
Prototype ProtoSendMessage(Window,Message,ParamL,ParamR)
Declare MsgTimeout(*x)
Procedure MsgBox(Title.s,Body.s,Timeout,Flags)
PokeI(*Timer,Timeout)
CreateThread(@MsgTimeout(),Timer)
MessageRequester(Title.s,Body.s,Flags)
EndProcedure
Procedure MsgTimeout(*x)
For x = 0 To PeekI(*Timer)
Delay(1000)
Next
If OpenLibrary(0,"User32.dll") = 0
Debug "Library error"
Else
FindAWindow.ProtoFindWindow = GetFunction(0, "FindWindowA")
SendAMessage.ProtoSendMessage = GetFunction(0, "SendMessageA")
hWnd = FindAWindow(0,Title.s)
SendAMessage(hWnd,#WM_CLOSE,0,0)
CloseLibrary(0)
End
EndIf
EndProcedure
MsgBox("My Title","My awesome timed message box!",5,#MB_OKCANCEL|#MB_ICONERROR)