Search code examples
autoit

How to make a message box to close the running process?


When the process is running I need a message box with "Cancel" and "Proceed" buttons:

  • Cancel = stop script (exit from script).
  • Proceed = kill the process to continue the script.

Solution

  • MsgBox() has some predefined button combinations (first parameter "Flag"):

    0 OK  
    1 OK and Cancel 
    2 Abort, Retry, and Ignore 
    3 Yes, No, and Cancel 
    4 Yes and No 
    5 Retry and Cancel 
    6 Cancel, Try Again, Continue
    
    $x = MsgBox(1, "Proceed?", "Want to continue?")
    ConsoleWrite($x & @CRLF)
    If $x = 1 Then ConsoleWrite("continuing..." & @CRLF)
    If $x = 2 Then ConsoleWrite("exiting..." & @CRLF)
    

    If you don't want to use them, you will have to build your own GUI instead.