Try this: #Include <Timers.au3> #include <WindowsConstants.au3> Global $hGUI = GUICreate("Hello world!",250,175,-1,-1) Opt("GUIOnEventMode", 1) GUISetOnEvent(-3, "exit_") ; Check if closed GUISetState() Global $iMs = 30 GUIRegisterMsg($WM_TIMER, "_Interrupt") DllCall("User32.dll", "int", "SetTimer", "hwnd", $hGUI, "int", 0, "int", $iMs, "int", 0) While 1 Sleep(50) WEnd Func exit_()&