Stefan wrote:
May i slightly suggest an thing like "Autohotkey_Install_folder\default.ahk"
for all such 'global' settings
who should work for all scripts on this pc
without 'always' including this '#Include' option.
...yes, I've wanted this too, since AutoHotkey.ini was only used when the .exe was run directly, I figured this global file could be named that, but I also figured you wouldn't want to re-purpose the .ini, so maybe Autoexec.ahk (or .ini)...or use AutoHotkey.ahk to do what AutoHotkey.ini does now & re-purpose AutoHotkey.ini to do the global thing. I have definitely wanted this, things that affect all scripts. You might as well re-purpose AutoHotkey.ini cuz I'm sure no one uses it for its current purpose (if they do they can rename it to .ahk & add the icon to their start menu) & you need an ahk program GUI to control settings. & .ini just screams "Settings!" AutoHotkey.ahk sounds like something that might run by default when the .exe is run.
Chris wrote:
Also, I'm thinking it might be better to have the default include file in %A_ScriptDir%.
...no, the global default should be in the ahk dir, another default could be in the script dir tho, currently my testing script is in the ahk dir, but I wouldn't want to be limited to leaving it there. I like the name Autoexec.ahk (or .ini) for the global one & Autoexec.ahk for the script dir one, default.ahk just has a bad ring to it, kinda like the M$ default.htm or .asp. If you look for both the global & the script dir one, make a check to see they're not the same dir or you'll end up execing the same script twice.
Chris wrote:
However, it also prevents subfolders from easily using the same default include file, so in that respect it is worse. Some more consideration of these issues will be needed before implementation.
...well, here's one option, it sounds excessive to me to, but it's an option...use the Apache .htaccess method, run the global Autoexec.ahk (or .ini), then look in the script dir for an Autoexec.ahk, then one dir up, then one dir up, all the way. This way you have the "server config" global file & the ".htaccess" per-directory files. If you have global ahk program settings somewhere (registry? do you?)...you could have options to limit the craziness this might cause, like an option..."Look a maximum of 5 dirs above script dir" (5 being configurable) & "Never look in root of drive" (if someone wants a global default, they can put it in the ahk program dir instead of c:\ {which would also be limited to scripts on C}, but have an option, in case someone wants to put it there). You could even use Autoexec.ini to be the settings file that determines what is looked for & run. Then people could set it to use Autoexec.ahk in the program dir for the global default & Autoexec.ahk in the script dir...one, the other, neither, both...even configure a different name for those who WANT it called default.ahk (why?)? You could also include an Autoexec.ini in the script dir, that can override loading the global default, this might eliminate the craziness...
C:\Program Files\AutoHotkey <--- here you set the sanity limit at 5
C:\Documents and Settings\User\My Documents\AHK Scripts <--- here you could have an Autoexec.ini that says "no higher"
Dir1
Sub1
SubSub1 <--- here you could have an Autoexec.ini that says "only global default",
___________so that none of the previous dirs are even checked
Sub2
Sub3
Dir2
Dir3
...the original idea was for an Autoexec.ini to control settings & an Autoexec.ahk to be the program that gets run, but this would require looking for 2 files in each dir, so maybe some # directives at the top of the Autoexec.ahk (or .ini) could control the searching...
Code:
#AutoInclude NoHigher
#AutoInclude Global
#AutoInclude -Global
#AutoInclude Global,ScriptDir
#AutoInclude Global,ScriptDir,Sanity5
#AutoInclude Global,ScriptDir,Sanity2-5
#AutoInclude Global,ScriptDir,Sanity5,NoRoot
#AutoInclude Global,ScriptDir,C:\This real dir
#AutoInclude Global,ScriptDir,.\This dir relative to current dir
#AutoInclude Global,ScriptDir,<This dir relative to ahk dir>
#AutoInclude Add,C:\This real dir
#AutoInclude Add,C:\Dir1,C:\Dir2
#AutoInclude Add,C:\Dir1,Global,Add,C:\Dir2
#AutoInclude +C:\This real dir
#AutoInclude +,C:\Dir1,C:\Dir2
#AutoInclude Sub,C:\This real dir
#AutoInclude -C:\This real dir
#AutoInclude -,C:\Dir1,C:\Dir2
...all of these being exclusive, you only include one #AutoInclude directive, but put all the options you want in it, separated by commas. Perhaps call it #Autoexec & not #AutoInclude? Sanity5 being what controls how many dirs above the script dir it will look in max, maybe call it Limit instead of Sanity, 5 being how many. Sanity2-5 is a min/max version, 2 is how many dirs to skip before it starts looking in the next 5 up...in the SubSub1 dir it would make it not look in Sub1 or Dir1, but would start looking in AHK Scripts & would keep on for 5 more max, but if the AHK Scripts dir says no higher, it would stop, if not it would never stop, because there aren't more than 5 dirs from AHK Scripts to root...basically it would be for deeply nested dirs, where it would be faster to not look in a few levels of dirs until it got out to where the file really is. If you wanted a min & no max, you could use Sanity2- Each directive resets the value so "#AutoInclude Global" means "only global", but "#AutoInclude Add,C:\This real dir" just adds that dir to the list...but non-directory options don't clear the search list, like NoHigher & NoRoot, they turn that option on, but leave the default/current search list alone. "-Global" means "remove Global from the list, leaving all other defaults" For ".\This dir relative to current dir" I'm not sure if current dir should mean script dir or the real working/current dir...?...or if by the time the script is running, they are the same thing? "<This dir relative to ahk dir>" is in the style of C "#include <windows.h>" that includes a file from a base dir, in this case the ahk dir, in C's case the header dir. Add would work until a non-directory is encountered in the list, so you only include the keyword once for each set of dirs to add. "+," is a synonym for Add. Sub is the opposite of Add (perhaps called Remove instead of Sub). "-," is a synonym for Sub (or Remove). The "-," (minus comma) version would start a list, like Add, but the "-" version, as used in "-Global" would only remove that item (not start a list), ditto for "+," & just "+". The last Add example is just to show someone being difficult, they could put Global anywhere but in the middle & not need the Add keyword twice, but it could/would control the search order, so it could be useful...search Dir1, then Global, then Dir2...hrm, using Add with Global is redundant, Global is default & you are Add'ing instead of resetting...so Global is already included...perhaps this could still be used to control order...?...or maybe when using the Add keyword, other options have no point...?...no, the NoHigher option would have a point even with Add, so a better example (of doing it a difficult way) is...
Code:
#AutoInclude Add,C:\Dir1,NoHigher,Add,C:\Dir2
...I left it this way to show the thought process & to leave the part about it controlling the search order.