Search code examples
timeoutautoitidle-timer

Autoit user Gui idle close Timeout


I created a GUI Program with Autoit.

I want to add a idle Timeout to my program to be automatically closed After the timeout has elapsed (Similar to InputBox & MsgBox). But it has no option for it...

Is ther any way to do it?


Solution

  • Using AdlibRegister

    GuiCreate() 
    
    AdlibRegister("MyTimeoutFunc", 10000); runs every 10s
    
    While True
      Sleep(100)
    Wend
    
    Func MyTimeoutFunc()
      Exit
    EndFunc
    

    Or using TimerInit and TimerDiff

    GuiCreate() 
    
    $sTimer = TimerInit() 
    
    While TimerDiff($sTimer) < 10000 ;Runs for 10s
      Sleep(100)
    Wend
    
    Exit