Dunno, I dunno what your intentions are for this code, but I'd flush it. I'm also not much of a fan of using KeyDown().
Do you want one application window, or do you want a popup window within another application?
For mainloops, why not use this:
Do you want one application window, or do you want a popup window within another application?
For mainloops, why not use this:
window=CreateWindow("..",0,0,640,480) Repeat WaitEvent() If EventID()=$803 And EventSource()=window ; if you only have one window in total, this eventsource check is not required If Proceed("sure?") quit=1 Else Notify "oO" EndIf Until quit End