Hello,
The #Include directive is a great way to keep your code organized as well as make your code much more maintainable. Think of using an #Include like having the file’s contents present at the exact position of the #Include directive.
So, if you have a dozen or so functions, you could have the function definitions in their own file (thus keeping your file much smaller and only having code that “does things” (meaning calls the functions / does actions).
The Standard, Local, and User Function Libraries
If you have a function you want to use frequently you can put it in one of three locations where AutoHotkey checks automatically!
- A_ScriptDir “\Lib\” ; Local library
- A_MyDocuments “\AutoHotkey\Lib\” ; User library
- “directory-of-the-currently-running-AutoHotkey.exe\Lib\” ; Standard library
For example if you have a function library file called MyFunc.ahk you can put that file in one of the three locations mentioned above and in your code you just have to use: #Include <MyFunc>.
Notice that you don’t have to put the full path to the file. You also don’t need to add the `.ahk` extension.
Autohotkey will automatically look for that file in the three locations above and correctly include in your main script!.
Learn more about functions and Includes in our Intro to AutoHotkey Course or get a 15% discount by clicking here.
Additional Resources
- AHKStudio automatically pulls all #include files to where your script is!
- XL Function Library
Joe, Isaias, Irfan & Team
This campaign was designed to allow you to jump around. At any time you can jump to any one of the emails by clicking below
P.S. If you are sharing your scripts with someone else, it’s easy to forget that you must put your includes somewhere the other person can access. Always remember to copy your included files into the lib folder❗

