Scripting: Can I delay (or prevent) quitting InDesign?

Participant ,
Aug 05, 2020 Aug 05, 2020

Copy link to clipboard

Copied

Hi,

 

I'm working on an Extension that does some checks on an Document. And I have an "beforeSave" listener that automatically does this when saving an document.

Works fine - the problem is in quitting InDesign. When the user quits InDesign and the document is not saved the user gets this "Save document" messagebox. User clicks "yes", document is saved and the extension is checking the document. But while checking Indesign is still quiting and my script can't finish the check of the document.

So my question: Is there a way to tell InDesign "Hey, don't quit! I'm working here!"? Or is there an "InDesign is quiting - don't start anything new"-flag that I can look for before I start my check?

 

Thanks

Klaus

TOPICS
Scripting

Views

104

Likes

translate

Translate

Translate

Report

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

correct answers 2 Correct Answers

Contributor , Aug 07, 2020 Aug 07, 2020
Klaus: Here's a snippet that allows the user to keep InDesign running if they have quit by mistake: #targetengine session app.eventListeners.add("beforeQuit",beforeQuitHandler) function beforeQuitHandler(evt) { if (!confirm("Do you want to quit now?")){ evt.preventDefault(); }// end if }  Seems to me that you might want to (a) remove the confirm code so that this handler always calls preventDefault() and (b) use your beforeSave function to install or remove the beforeQuit event-listener as...

Likes

translate

Translate

Translate
Adobe Community Professional , Aug 07, 2020 Aug 07, 2020
So my question: Is there a way to tell InDesign "Hey, don't quit! I'm working here!"? Or is there an "InDesign is quiting - don't start anything new"-flag that I can look for before I start my check?   Do you want to throw up a warning dialog or simply delay the quit? This would delay the quit for 5 sec.   #targetengine session app.eventListeners.add("beforeQuit",beforeQuitHandler) function beforeQuitHandler(evt) { $.sleep(5000); }      

Likes

translate

Translate

Translate
Contributor ,
Aug 07, 2020 Aug 07, 2020

Copy link to clipboard

Copied

Klaus:

 

Here's a snippet that allows the user to keep InDesign running if they have quit by mistake:

 

#targetengine session
app.eventListeners.add("beforeQuit",beforeQuitHandler)

function beforeQuitHandler(evt) {
	if (!confirm("Do you want to quit now?")){
		evt.preventDefault();
	}// end if
}

 

Seems to me that you might want to (a) remove the confirm code so that this handler always calls preventDefault() and (b) use your beforeSave function to install or remove the beforeQuit event-listener as needed.

 

Hope this helps.

 

Likes

translate

Translate

Translate

Report

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
Adobe Community Professional ,
Aug 07, 2020 Aug 07, 2020

Copy link to clipboard

Copied

So my question: Is there a way to tell InDesign "Hey, don't quit! I'm working here!"? Or is there an "InDesign is quiting - don't start anything new"-flag that I can look for before I start my check?

 

Do you want to throw up a warning dialog or simply delay the quit? This would delay the quit for 5 sec.

 

#targetengine session
app.eventListeners.add("beforeQuit",beforeQuitHandler)

function beforeQuitHandler(evt) {
    $.sleep(5000);
}

 

 

 

Likes

translate

Translate

Translate

Report

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