Home > InDesign Scripts > Check/Destroy all opened dialogs

Check/Destroy all opened dialogs

This is short one, but I use it in some of my scripts. Sometimes, script just hangs, or crashes, and if we used windows in script, they are not destroyed! They are still in memory and they will be there until we close InDesign. But, there is way to destroy all dialogs that are left in memory.

First, we can check is there some opened dialogs like this:

var openedDialogs = app.dialogs.length;

So, now we got dialogs count. If number is zero then we’re good, but what if it’s not?! There is very easy way to destroy all opened windows at once. All we have to do is first to check is there any opened window left, and if there is, any, we just destroy it. We select every item in app.dialogs with everyItem() and then we just destroy() them all 😀

if (app.dialogs.length > 0) app.dialogs.everyItem().destroy();

That’s it’ Hope it helps 😉

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: