Keyword Reference

#include

Includes a file in current script.

#include "[path\]filename"
#include <filename>

 

Parameters

filename The filename of the current script to include. Path is optional. This must be a string--it cannot be a variable.
If "..." is used, the filename is taken to be relative to the current script.
If <...> is used the filename is taken to be relative to include library directory (usually C:\Program Files\AutoIt3\Include). The include library contains many pre-written user-functions for you to use!

 

Remarks

In an AutoIt script, other scripts can be included using the #include" command. #include must be in lower-case.

For the include library syntax (#include <file>) to work AutoIt must have been installed using the supplied installer otherwise the installation directory will not be known and the current script directory (@ScriptDir\Include) will be used instead.

If you include the same file containing a user-function more than once you will get a "Duplicate function" error. When writing an include file that may be used in this way, make sure that the top line contains #include-once to prevent that file from being included more than once.

 

Related

#include-once, FileInstall

 

Example

;;; TIME.AU3 ;;;
MsgBox(0,"", "The time is " & @HOUR & ":" & @MIN & ":" & @SEC)

;;; SCRIPT.AU3 ;;;
#include "TIME.AU3"
MsgBox(0,"", "Example")
#include "TIME.AU3"
Exit

; Running script.au3 will output three message boxes:
; one with the time, one with 'Example', and another with the time.