When bad things happen to good script panels…

The other day most of my cool scripts for InDesign CS3 just suddenly quit working. Without any warning or explanation, they just stopped executing themselves, rendering my scripting palette an inviting but mostly inert list of good productivity intentions. This not the sort of behavior one expects or appreciates from one’s favorite application, and I have to say that I took it rather personally. Betrayal may be too strong a word, but if you’ve ever loved and lost your scripts, you know what I mean.

Fortunately, scripting deity Olav Kvern was in his office and was kind enough to diagnose my problem immediately. It seems that somehow InDesign’s scripting preferences had been altered without my knowledge…and that’s the way it will most likely happen to you as well.

InDesign’s scripting guides explain it in a bit more detail, but the short version is that you can tell InDesign (via a script, of course) whether or not to allow alerts and dialog boxes to be displayed when a script is executed. This can be a very useful thing to tweak when you’re running scripts that know exactly what they’re doing and can’t be bothered by unwanted alerts and other unnecessary interruptions by InDesign. On the other hand, turning off this setting can also block the execution of any script that wants to generate an alert or dialog box within InDesign. Dang.

It’s an important requirement of good scripting hygiene to restore alert and dialog generation if you’ve exercised the option of turning it off for the purposes of executing a script in the most efficient way. It’s analogous to turning off one of the breakers in your electrical panel in order to install a new light fixture or perform a repair —if you want lights to be able to come back on when you need them, you need to flip the breaker switch back to the ‘on’ position when you’re done with your repair.

What probably happened to me was that I ran a script that altered the userInteractionLevel property, but neglected to restore it to its original state as part of the completion of its mission. The fix is to run a script that restores that setting to its proper state.

Here’s the javascript you need should this ever happen to you:

app.scriptPreferences.userInteractionLevel = UserInteractionLevels.interactWithAll;

Copy and paste this text into a text editor and save it into InDesign’s scripts folder with a name that describes what it does. Olav named mine RestoreUI.jsx. All it does is restore the user interaction script preference to its original, fully functional state.

Comments are closed.