First of all, let me clarify that the standard library will be discovered in the folder of the AutoHotkey.exe that was just launched, which isn't necessarily the one where AutoHotkey was installed. This seems to be justified due to portability.
Titan wrote:
It shouldn't be so difficult to create a post-install macro to hack the exe, just decompress and binary search & replace. Don't forget that you can modify AutoHotkeySC.bin for compiled scripts so it won't be a new concept for many users. Registry is not an option because it breaks portability and INI is simply too slow.
I think altering the EXE is too non-traditional to be seriously considered. The auto-included .ahk file (config/settings), while it might add a 50ms delay to startup when uncached, is probably the lesser evil. In fact, there might be no delay at all if the settings file doesn't exist, which for most people it won't.
corrupt wrote:
The name Include is already an established name for the action that will be performed. It seems to fit quite well. To have something auto-included in a script then give the file the same name as the function and place it in the Include folder. This has the advantage of simplifying the documentation (possibly just adding a few lines to #Include in the help file) and clearly describing what is taking place.
That is a good point; but it appears that choice is a small minority unless others have changed their minds.
Laszlo wrote:
Another alternative was to first search the directory of the script for its includes, maybe followed by %A_ScriptDir%\include.
At first glance, I think the benefit/cost is poor due to its added complexity and rarity of use.
Laszlo wrote:
Maybe the registry? If keys StdLib/UserLib are not set, use some standard locations, otherwise use the specified directories. Other behaviors of AHK can be controlled via registry entries, too, to be temporarily overridden by command line parameters.
Currently, I don't like the idea of having both command-line parameters and registry entries. For one thing it's complicated, both in code and documentation. For another, the registry is somewhat icky for things like this because it reduces the portability of AutoHotkey.exe; furthermore, a lot of people simply don't like it when software relies heavily on the registry.
In summary, I think there are only 3 approaches: registry, environment variables, and config/settings file. The first two seem undesirable, mostly due to lack of portability, but also because they may require a high-privileged user to make the changes. The latter (config file) -- while also clearly undesirable (and a bit slower during launch) -- seems like the lesser evil. Another advantage of having a config file is that it can be a generic .ahk script that is auto-included at the top of every script. It could contain any commands or directives, most notably a directive like
#userlib C:\My Custom Lib Location.
The config file would be discovered in the same folder as the AutoHotkey.exe that was just launched, which isn't necessarily the one where AutoHotkey was installed. However, this config-file feature won't be in the next release, so there will be more time to discuss it.
Tuncay wrote:
I agree with corrupt. This could be done with an INI settings file, found in AutoHotkey folder. So, any script run with that AutoHotkey.exe you want, would access to YOUR configuration file.
Yes. The key concept is that the config file would always be in the same directory as the AutoHotkey.exe that is being launched. There would be no dependency on the registry or on having run the AutoHotkey installer.
corrupt wrote:
The problem seems to be with the User directory. A simple solution could be something like:
Code:
#Include <%A_ScriptDir%\Include>
where the path between the <> characters gets designated as the User directory to use. This could be convenient to ignore files in the User directory too:
Code:
#Include <> ; ignore User directory
Instead of overloading #Include, I prefer some kind of new directive. Perhaps
#lib stdlib > userlib > C:\OtherDir > ..., which would set the search order. To change the user lib, it could be
#userlib C:\My Includes
Thus, the directive
#lib stdlib could be used to force only the stdlib to be used for lookups (i.e. omit userlib). This would allow publicly-posted scripts to avoid any chance of interference from a userlib.
Those who voted for "Lib" in the poll: if you feel strongly about lib vs. library, please state the reasons. Otherwise I'll probably go with Library or Include under the assumption that most everyone can live with it.
Thanks.