Copy link to clipboard
Copied
In ExtendScript, I've run up against a very strange scenario with which I need some help from a ScriptUI guru. I've got a huge InDesign script that, during the course of its execution, displays a progress bar in a palette window:
var w = new Window("palette", "Progress");
I would like this palette to be closed when the script is finished, so I added a w.close() at the end of the script.
However, this only occurs if the focus is still in InDesign. Some of our people like to work on other tasks while the InDesign script is running on another screen in the background, which is fine, but when they return to InDesign, that progress bar palette is still on the screen, showing 100% completion. This palette window can be moved around, but it cannot be closed, even if the little red 'x' in the corner is clicked. This eventually leads to multiple palettes staying on the screen throughout the day, as this script is called dozens of times in a normal workday.
Reading Peter Kahrel's excellent guide to ScriptUI, I learned that all palettes remain in memory, even after being closed with .close(). I want them completely erased from memory and purged, so they don't stay on the screen if the user switches to another application while the script is running. Any ideas on how to accomplish this?
By the way, I wanted to include some sample code so you could see for yourself, but it doesn't seem to work when it's just some small code called from with the ESTK; only in my 4,647-line production script. Thus, I cannot paste any example code.
Copy link to clipboard
Copied
Moved to the scripting forum...
Copy link to clipboard
Copied
Destroy works with dialog boxes, did you try w.destroy();
Copy link to clipboard
Copied
Tried and failed. Got an error message that "progressWin.destroy is not a function".
Copy link to clipboard
Copied
.destroy() is a method of InDesign's classic dialog system, it doesn't work with ScriptUI. I thought that Marc Autret had some code recently dealing with removing variables, but I can't find the link and googling doesn't give any result. Does anybody remember that thread? It was fairly recently.
Peter
Copy link to clipboard
Copied
Hello Peter,
do you mean this post?
http://www.indiscripts.com/post/2013/12/indesign-scripting-forum-roundup-5#hd3sb2
Roland
Copy link to clipboard
Copied
Thank you, Roland, that's the one.
Peter
Copy link to clipboard
Copied
Thanks Roland for the mention.
Anyway: keep in mind that nullifying the Window reference after closing the UI — F.W=null; delete F.W; in my snippet — still leads to odd crashing instants in CC, as reported by Trevor in another topic.
@+
Marc
Copy link to clipboard
Copied
Finally got around to responding to the recent posts in here. I'm very sorry for the delay.
We're still using CS6 here at work, so hopefully we won't have any of the CC crashing issues that you mention, Marc. However, looking at the code snippet you provided in your post from December, I'm a little confused. For instance, I don't see $.UserInterface documented anywhere in the InDesign CS6 DOM. I also don't understand how your use of the Logical OR operator (II) is being used in so many places, yet it's not actually combining two booleans.
Please bear with me. I've never dealt with anything like this so far in my usage of ExtendScript.
Copy link to clipboard
Copied
I found a solution like that:
OKNO = new Window ("palette");
...
OKNO.onActivate = function () { blablabla }
OKNO.onClose = function() { OKNO.hide(); OKNO.close(); OKNO.onActivate = NOP(); }
I binded empty function NOP() to .onActivate in .onClose ().
If I click red close cross, palette is closing and illustrator CS6 not crashing
and soo... Not show closed palette window again
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more