This idea is just brute force to get things into the box you want to close. It let’s the library do what it wants and then stomps a boot on it. Hopefully somebody has a more eloquent solution, but maybe this will at least trigger an idea for someone.
We need to be able to execute some code prior to ID being triggered. I don’t know enough about using libraries to know if that code can be put before the library call, or it would need to be a separate setup script that then runs the main script.
When the script starts, make a quick check to see if ID is open and what is the window state. (This is the part that needs to be before ID is triggered by the script.)
If ID is open, let the script run normally and leave ID in the background. If the library call brings it to the foreground, shove it back down to whatever window state it had initially.
Else wait for ID to be triggered and immediately exit it. (Stomp a boot on it.)
Not an eloquent solution at all, but it might work well enough.
Not really. Script Debugger builds lists of handlers in used libraries for the purposes of code-completion, and extracting that information can result in loading of dictionaries.
Putting the Script Library mechanism aside for some purposes, and including a source file directly as a script object ?
-- prelude :: FilePath -> Script
on prelude(filePath)
-- (path to a library file which returns a 'me' value)
set ca to current application
set {bln, int} to (ca's NSFileManager's defaultManager's ¬
fileExistsAtPath:((ca's NSString's stringWithString:filePath)'s ¬
stringByStandardizingPath) isDirectory:(reference))
if (bln and (int ≠ 1)) then
set strPath to filePath
run script (((ca's NSString's ¬
stringWithString:strPath)'s ¬
stringByStandardizingPath) as string)
end if
end prelude