Question about script libraries

I have a script that tries to open InDesign every time it launches. But there are no inDesign calls in the script.

But it does call a library and that library does contain inDesign calls.

I figure that’s why it’s launching inDesign.

But, when I open it in Script Editor it doesn’t launch inDesign (and doesn’t launch it at runtime).

If that’s why ID is being launched, is there any way to stop that?

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.

  1. 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.)

  2. 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.

  3. 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.

1 Like

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