-----------------------------------------------------------------------------

AutoIt

Q #1: Does the Exit command work in the AdLib section?
 
      ---------------------------------------------------------------------

A #1: No, the Exit command does not function from an ADLIB line, as in

      ; ======= Scriptlet Starts Here =======
      [ADLIB]
      Some Window, Some text, Exit
      ; ======= Scriptlet Stops Here =======

      However, the same thing can be achieved by replacing "Exit" with
      "Goto, ExitLabel" and adding the lines "ExitLabel:" and "Exit"
      similar to the following scriptlet.

      ; ======= Scriptlet Starts Here =======
      SetTitleMatchMode, 2
      AdLibOn

      SetEnv, Count, 1
      Loop:
      MsgBox, 0, The Beginning, Count = %Count%   \n
      EnvAdd, Count, 1
      IfEqual, Count, 5, Run, notepad.exe
      IfEqual, Count, 11, Goto, ExitLabel
      Goto, Loop

      ExitLabel:
      WinWaitActive, - Notepad
      Winclose, - Notepad
      Exit

      [ADLIB]
      - Notepad, , Goto, ExitLabel
      ; ======= Scriptlet Ends Here =======

-----------------------------------------------------------------------------

Q #2: Can a "GoSub" be used in an AdLib statement?

      ---------------------------------------------------------------------

A #1: Yes.  See the script below for an example.

      ; ======= Script Starts Here =======
      SetTitleMatchMode, 2
      AdLibOn

      SetEnv, C, 1
      SetEnv, Count, 11
      Repeat, %Count%
            IfEqual, C, 5, Exit
            EnvAdd, C, 1
            Run, Notepad.exe
      EndRepeat

      Exit

      Notepad:
            Send, !fx
      Return

      [AdLib]
      - Notepad, , GoSub, Notepad
      ; ======= Script Stops Here =======