Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Destroying ScriptUI Palette Windows

Engaged ,
Feb 06, 2014 Feb 06, 2014

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.

TOPICS
Scripting
4.0K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 06, 2014 Feb 06, 2014

Moved to the scripting forum...

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 06, 2014 Feb 06, 2014

Destroy works with dialog boxes, did you try w.destroy();

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Feb 06, 2014 Feb 06, 2014

Tried and failed.  Got an error message that "progressWin.destroy is not a function".

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 07, 2014 Feb 07, 2014

.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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Feb 08, 2014 Feb 08, 2014
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 09, 2014 Feb 09, 2014

Thank you, Roland, that's the one.

Peter

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Feb 09, 2014 Feb 09, 2014

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Mar 19, 2014 Mar 19, 2014

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Dec 15, 2017 Dec 15, 2017
LATEST

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines