# Keyword Reference

# #include

Includes a file in the current script.

#include <filename>
#include "[path\]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 include library directory (usually C:\Program Files\AutoIt3\Include). The include library contains many pre-written user-functions for you to use! If "..." is used, the filename is taken to be relative to the current script.

## Remarks

Other scripts can be included into an Autoit script using the #include command - these can be in either .au3 or .a3x format. The content of the included file is inserted into the script at the point of the #include command - in most cases this is the beginning of the script so that any variable or constant declarations within the included text are available to the rest of the script.
If you include the same file containing a user defined 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 firstline contains #include-once to prevent that file from being included more than once.
There is a special registry value that can be created at "HKEY_CURRENT_USER\Software\AutoIt v3\AutoIt" called "Include". It should be a REG_SZ (string) value. The contents of this value are a semi-colon delimited list of directories that should be searched for files when resolving #include's in addition to the standard locations.
The search order used by AutoIt depends on which form of #include you use. The tables below show the order directories are searched using both forms.
Using #include <>

Standard library | The path of the currently running interpreter with "\Include" appended is searched.
User-defined libraries | The registry value mentioned above is read and each directory is searched in the order they appear in.
Script directory | The directory of the currently executing script.

Using #include "" (This is the reverse of #include <>).

Script directory | The directory of the currently executing script.
User-defined libraries | The registry value mentioned above is read and each directory is searched in the reverse order they appear in.
Standard library | The path of the currently running interpreter with "\Include" appended is searched.

A note about using the /AutoIt3ExecuteScript option. Since the standard library is searched for in the current interpreter's directory, the standard library functions will not be found; that library will only be found when run through AutoIt3.exe. It's recommended that you compile a script to the .a3x format before attempting to run it with /AutoIt3ExecuteScript.
Aut2Exe uses the same algorithm as AutoIt3.exe with the only difference being it looks for the Include sub-directory as being in a sibling directory to itself (..\Include).
If Opt("TrayIconDebug",1) only 64 include files name can be displayed in the traytooltip. for the other no filename will be displayed.

## Related

#include-once

## Example

    #include "include-TIME.au3"

    #include <MsgBoxConstants.au3>

    ; Running "include.au3" will output two message boxes:
    ; one with the time, followed by one with 'Example'

    MsgBox($MB_SYSTEMMODAL, "MsgBox #2", "Example")

    Exit