Copy link to clipboard
Copied
A week or two ago, I wrote a script to pop up a dialog box after any background export, in response to the InDesign CS5 PDF export status thread. It doesn't seem like there's been feedback. I suspect it's sort of gotten lost in the noise in the general forum. So here we go again!
Don't make me post it to InDesign Secrets!
This script will automatically pop up a dialog box after every export finishes (PDF, IDML, whatever). It also makes sure that the Background Tasks window is turned on.
You can download the script from here, or just paste in what follows and save as exportPop.jsx. See How to Install InDesign Scripts for installation instructions. If you save it in the Startup Scripts folder, it will run automatically when InDesign is started. Running it a second time disables it, if for some reason it causes problems.
// exportPop.jsx -- pops up Background Tasks when you start an export // and a modal dialog when an export finishes. // Beta version. Please post feedback at // http://forums.adobe.com/thread/830572 // John Hawkinson, 17 March 2011 // Save in STARTUP SCRIPTS folder to start automatically. #targetengine session (function() { var old1 = app.eventListeners.itemByName("exportPop1"), old2 = app.eventListeners.itemByName("exportPop2"); if (old1.isValid || old2.isValid) { if (old1.isValid) { old1.remove(); } if (old2.isValid) { old2.remove(); } alert("Export pop up window removed.\n"+ "Indesign will behave as normal."); return; } app.addEventListener("beforeExport", function() { var tasksPanel = app.panels.itemByName("Background Tasks"); if (tasksPanel) { tasksPanel.visible=true; } }).name = "exportPop1"; app.addEventListener("afterExport", function(ev1) { var task, listener; task = app.idleTasks.add({ name: "exportPop", sleep: 1000}); listener = task.addEventListener(IdleEvent.ON_IDLE, function(ev2) { listener.remove(); task.remove(); alert(ev1.format+" export complete of " +ev1.fullName+" at "+ev1.timeStamp); }); }).name = "exportPop2"; alert("Export pop up window installed\n"+ "Background Tasks will appear the start of an export\n"+ "and a dialog will appear after each export complete."); }());
Copy link to clipboard
Copied
Cool!
Nice job.
Harbs
Copy link to clipboard
Copied
Hi John,
Very interesting ! Weeks ago I tried to catch events adding eventListener to backgroundTask and went into deadend. I was then sure background tasks could'nt be monitored but your script show me that indeed it is ! It opens me a lot of perspective
Loic
Copy link to clipboard
Copied
Thanks for doing this - it works for me and removes one annoyance from CS5, that I would forget to open the window before exporting (and finding that the background export had hung, while I waited for something to happen). Now I have an immediate heads up!
Thanks for sharing.
Copy link to clipboard
Copied
re: don't make me post to indesignsecrets
LOL! Well, honestly, there's a reasonable chance that it would find a wider audience there.
Mind if I post it there, too?
--david blatner
(you can contact me directly if you want: david at indesignsecrets.com)
Copy link to clipboard
Copied
Great work John!
I've got idea how to enhance this script even more
You could create panel with list of finished files
with all info (path, file size, file name, etc...)
It would be great way to track finished files.
--
Marijan (tomaxxi)
http://indisnip.wordpress.com/
http://inditip.wordpress.com/
Copy link to clipboard
Copied
Hmm. Nice ideas!
And buttons to open the resulting files would be very cool as well!
Harbs
Copy link to clipboard
Copied
Yes Harbs, it would be great to have button to open resulting PDF!
But this time, real panel (not ScriptUI palette) would be better!
Name: Background Tasks History
Maybe ability to edit PDF Metadata (XMP), FTP Upload...
Cool feature: Send email notification after export complete
--
Marijan (tomaxxi)
Copy link to clipboard
Copied
I'm liking the sound of this! You're whetting my appetite!
Wanna do this together?
Copy link to clipboard
Copied
Wow, you guys are really getting excited!
I thought about adding a UI and decided that it would get too complicated, and it's hard to do really solid UIs in ScriptUI and I didn' want to go mess with ActionScript/FLEX/CSXS/etc. for something that nobody actually admitted to wanting to use :-).
But I think you guys should go ahead! Seems like there's a market.
Copy link to clipboard
Copied
Hi John,
I used your script and it is working fine. It will give an alert message after completion of PDF export. This is nice, but when I copy some text from Indesign and pasting it into some other application like Word, ESTK... here also it gives a alert message. Actually do you want to include these cases also?
Thanks,
Green4ever
Copy link to clipboard
Copied
That is unexpected. What is the text of the alert message, or a screenshot?
Copy link to clipboard
Copied
Hi John I got this error message while copying the text to MS word application.....
Thanks,
Green4ever
Copy link to clipboard
Copied
Hmm. I wonder if it is better to filter these based on the export type, the empty document name, or both.
Copy link to clipboard
Copied
I think document name/path would be enough.
Also you need to check what will happen when you
copy stuff from InDesign to Illustrator because it will use PDF for transfer.
--
Marijan (tomaxxi)
Copy link to clipboard
Copied
It appears not.
Under OSX, cutting and pasting to Illustrator doens't produce an export popup.
Cutting and pasting text does, with a null document: "Sangam Clipboard Unicode Text Export export complete of at Thu Mar 31 2011 01:02:35 GMT-0400."
Dragging-and-dropping objects into Firefox produces: "InDesign Snippet export complete of /private/var/folders/kN/kNzi33+jHq0d7nd2+GTGGU+++TM/-Tmp-/Cleanup%20At%20Startup/InDesign%20Snippets/Snippet_303A4A9D5.idms at Thu Mar 31 2011 01:01:57 GMT-0400" and that is kind of awkward.
I'm not sure what a reasonable filtering case is for these. I don't want to filter out snippets and I'm not sure filtering out termporary directories is wise. Their use by people is rather uncommon, but scripts may use them...blah.
Copy link to clipboard
Copied
John Hawkinson wrote:
I'm not sure what a reasonable filtering case is for these. I don't want to filter out snippets and I'm not sure filtering out termporary directories is wise. Their use by people is rather uncommon, but scripts may use them...blah.
But would you really want your script to interupt execution of a script which writes to the temporary folder? I'd think not. At least I think it'd be a good idea to have your script honor the current value of app.scriptPreferences.userInteractionLevel as to not interfere with scripts that have requested it shouldn't.
Copy link to clipboard
Copied
This is a classic example of how something very simple becomes not so straightforward when you get into the details...
Harbs
Copy link to clipboard
Copied
Whoops, sorry for the delay. Here's a version that honors app.scriptPreferences.userInteractionLevel and also checks to make sure it is exporting either a PDF or IDML. I'd especially appreciate someone confirming this works properly for InDesign that's not US English.
// exportPop.jsx -- pops up Background Tasks when you start an export
// and a modal dialog when an export finishes.
// Beta version. Please post feedback at
// http://forums.adobe.com/thread/830572
// John Hawkinson, 17 March 2011. This revision 20 April 2011.
// $Id: f4055778c272f8d200d27f7ca7a63450dd1bdf7f $
// Save in STARTUP SCRIPTS folder to start automatically.
#targetengine session
(function() {
var
old1 = app.eventListeners.itemByName("exportPop1"),
old2 = app.eventListeners.itemByName("exportPop2"),
types = [ '$ID/InDesignMarkup', '$ID/Adobe PDF (Print)',
'$ID/Adobe PDF (Interactive)'],
i, typeFilter = {};
for (i=0; i<types.length; i++) {
typeFilter[app.translateKeyString(types)]=1;
}
if (old1.isValid || old2.isValid) {
if (old1.isValid) { old1.remove(); }
if (old2.isValid) { old2.remove(); }
alert("Export pop up window removed.\n"+
"Indesign will behave as normal.");
return;
}
app.addEventListener("beforeExport", function() {
var
tasksPanel = app.panels.itemByName("Background Tasks");
if (tasksPanel) { tasksPanel.visible=true; }
}).name = "exportPop1";
app.addEventListener("afterExport", function(ev1) {
var task, listener;
if (app.scriptPreferences.userInteractionLevel===
UserInteractionLevels.NEVER_INTERACT ||
!typeFilter.hasOwnProperty(ev1.format) )
{
return;
}
task = app.idleTasks.add({ name: "exportPop", sleep: 1000});
listener = task.addEventListener(IdleEvent.ON_IDLE,
function(ev2) {
listener.remove();
task.remove();
alert(ev1.format+" export complete of "
+ev1.fullName+" at "+ev1.timeStamp);
});
}).name = "exportPop2";
alert("Export pop up window installed\n"+
"Background Tasks will appear the start of an export\n"+
"and a dialog will appear after each export complete.");
}());
I'm always suspicious of app.translateKey and app.findKeyStrings, especially when the latter returns stuff with spaces.. But there doesn't seem to be a better keystring for the PDF export formats.
Incidently, ImportExportEvents and DocumentEvents have their own userInteractionLevels property. I figured it would probably be the value of the scriptPreference at the time the event was dispatched, but that doesn't seem to be the case. Any clues?
Please note, Mayhem, that since app.scriptPreferences.userInteractionLevels seems to be different in every engine, I'm not sure there is much point in this check. But it does not hurt, so there we go.
How's that CSXS extension coming, guys?
Copy link to clipboard
Copied
Anyone? Could someone test the above version in a non-English version of InDesign?
Copy link to clipboard
Copied
Hey John,
Here is little update on our little work
--
Marijan (tomaxxi)
Copy link to clipboard
Copied
By the way, are you guys aware that the source to the Background Tasks panel is in the SDK in source/open/components/backgroundtaskspanel?
While I'm pretty sure I knew this fact at one time, I definitely forgot at the time you all were discussing this extension...
Copy link to clipboard
Copied
Thanks John, for your work! 😃
Copy link to clipboard
Copied
Hello,
First of all, Thanks John for this great script. It fits my work method perfectly!
Now,
Although I should have posted this question here first, This is the 3rd place posting it... hoping to find someone that can help!
Recently something very funny started happening in my InDesign (Mac OS 10.8 - InDesign CS6 8.01)
Everytime I copy text the backround task panel opens up like this:
It happens when copying using Cmd+C and when using context menu
After a little digging I found that when I disable the exportpop script, I stopped getting the task panel!
However:
1) I've been using this script for a while now and never had this problem.
2) Why should copying be considered like exporting?????
If anyone can shed light on this topic, I'd really appreciate it
Thanks
Davey
Copy link to clipboard
Copied
Huh. That's a first.
Do you have any idea what might have changed?
Upgrade of the OS or upgrade of InDesign?
Anything else?
Spyware installed by an arch-rival or the NSA?
The script, of course, just uses InDesign's idea of an "export." Specifically, it registers a handler for InDesign's "beforeExport" event, and whenever InDesign decides there is going to be an export, it calls the beforeExport handlers. So it really lets InDesign decide.
My best guess (which is not very good) is that this relates to clipboard stuff. There are some cases where copying something in InDesign and pasting it into some other program might cause InDesign to convert the copied items into IDML. I think this might happen if you copy/paste across two versions of InDesign that are simultaneously running? Now, this conversion to IDML is probably internally an "export," and so, in its own tortured way, could explain this. I would expect the export to happen on Paste and not on Copy, but I know the way clipboards work is actually way more complicated than you would think.
So, are you running multiple copies of InDesign simultaneously?
Or alternatively, if you exit all other open apps, does it still happen? Perhaps you might need to trash your prefs again after doing so (I see from your earlier thread that you did try trashing your preferences. DId you do it by holding down Cmd-Opt-Shift-Control while starting ID?)
I suppose there is probably some way to filter out these copying events.
Try changing this portion of the script:
app.addEventListener("beforeExport", function() {
var
tasksPanel = app.panels.itemByName("Background Tasks");
if (tasksPanel) { tasksPanel.visible=true; }
}).name = "exportPop1";
to this:
app.addEventListener("beforeExport", function(ev2) {
var
tasksPanel = app.panels.itemByName("Background Tasks");
if (tasksPanel) { tasksPanel.visible=true; }
alert("debug: export format was "+ev2.format);
}).name = "exportPop1";
And report back what it says the format of the export was. Then we could modify the script to filter it out, hopefully.
Or if that's not helpful, you could replace the above new alert() line with:
var s = [];
for (i in ev2.properties) {
s.push(i+": "+ev2.properties+
"("+ev2.properties.constructor.name+")");
}
alert("afterExport\n"+s.join("\n"));
which will collect up all the properties of the event and display them in the alert, and we should be able to figure something out.
Sorry for not seeing your earlier posts.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now