Pre-execution Code
Posted: 29 Nov 2017, 14:44
It would be useful to have the ability to pre-execute code prior to loading any scripts. Say, you have hundreds of scripts and want to apply `#Include <MyClass>` to all of them. Currently you have to insert the line in every single script. I'd like to see a more convenient way for it. Not only including classes, this allows us to pre-set directives like `#NoEnv`, `#SingleInstance, Force` etc.
When `AutoHotkey.exe` is double-clicked, it first tries to find AutoHotkey.ahk in the same directory or the current user's Documents directory and executes it if exists. I'm wondering whether a similar approach could be done. Like, if there is AutoHotkey.ini (the name can be settings/config/manifest and the file extension can be xml/yaml/json or whatever) in the same directory, AutoHotkey.exe tries to read the settings from it. Then if there is an entry like `PreExecutionPath`, then it loads the code of that specified file path before loading the actual script code.
Another idea to achieve the suggested functinality is that when a reserved file name (like `.ahk` without any base name or whatever) is in the `Lib` direcotry, `AutoHotkey.exe` first loads the code of that file and continues the actual script.
This adds an overhead of checking file existence, however. To avoid that, this behavior can be enabled only when a switch in script arguments such as `/pre` is passed.
When `AutoHotkey.exe` is double-clicked, it first tries to find AutoHotkey.ahk in the same directory or the current user's Documents directory and executes it if exists. I'm wondering whether a similar approach could be done. Like, if there is AutoHotkey.ini (the name can be settings/config/manifest and the file extension can be xml/yaml/json or whatever) in the same directory, AutoHotkey.exe tries to read the settings from it. Then if there is an entry like `PreExecutionPath`, then it loads the code of that specified file path before loading the actual script code.
Another idea to achieve the suggested functinality is that when a reserved file name (like `.ahk` without any base name or whatever) is in the `Lib` direcotry, `AutoHotkey.exe` first loads the code of that file and continues the actual script.
This adds an overhead of checking file existence, however. To avoid that, this behavior can be enabled only when a switch in script arguments such as `/pre` is passed.