AutoHotkey auto-includes the file after processing the main script, during the stage that it resolves function names to addresses. The physical end of the (main) script ends the auto-execute section (as documented), so any lines added after that are not part of the auto-execute section.
Ahk2Exe reads all include files and combines into one. It runs AutoHotkey.exe /iLib to determine which files should be "auto-included". It presumably does not add an "Exit" at the end of the main script prior to "auto-included" files, so it is possible for them to auto-execute. This could be considered a bug in the compiler.
teadrinker wrote:If it's included, is there a way to get its value?
Get whats value? The assignment hasn't been evaluated, so the variable has no value. If you know where the file is, you can read it and parse the assignment. But you are better off using
#include <libname> in the auto-execute section instead. You could alternatively utilize a static initializer to have a function be called automatically, as I mentioned.