Closing library panels at beginQuit event
Hello,
I'm trying to have a javascript run when the user quits InDesign (CS5), and close all the Library Panels.
The code below (that only closes the Library Panels) works perfect if ran from ExtendScript. But once I add the EventListener code and then place it in the startup scripts folder, it will loop but never close any panel. I added the 'n' character so as not to get caught in the infinite loop.
I've also experimented trying to do this when InDesign is first launched, but it doesn't seem to work either. I'm wondering if it has something to do with how events work in InDesign, and maybe the Library Panels aren't accessible at these points?
Any insight would be appreciated. Thanks!
-------------------------------------------------------------------------------------------
app.addEventListener('beforeQuit', save_library, false);
function save_library(theEvent) {
var n = 0;
while(app.libraries.length > 0) {
var lib = app.libraries[0];
alert(lib.name);
//lib.close();
app.libraries[0].close();
n++;
if (n > 7) { break; }
}
}
-------------------------------------------------------------------------------------------
