Indesign Startup script gets triggered by Copy key (command+c)

Explorer ,
May 27, 2021 May 27, 2021

Copy link to clipboard

Copied

Hello everyone, Im having a bit of a problem on my startup script. The script simply scan if the open IND file contains any unwanted layers base on the list that I set on the script then it will show a dialog box with a list of those unwanted layers upon export. The problem is, whenever I press command+c Inside and outside the Indesign this dialog box keeps popping out. Is there any way to fix this? Thanks in advance

TOPICS
Bug, How to, Scripting

Views

307

Likes

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 ,
May 27, 2021 May 27, 2021

Copy link to clipboard

Copied

Can you show us the event listner that you have put in that code?

 

If you can share it, then we might get idea why it is behaving in that sense.

 

Sunil

Likes

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
Explorer ,
May 28, 2021 May 28, 2021

Copy link to clipboard

Copied

@Sunil Yadav  Hey man! youre the one who helped me with this script and I really appreciate it, its very usefull. Unfortunately I cannot resolve the problem above. Heres the code:

 

#target indesign
#targetengine "session"
main();
function main(){
var myBeforeExportEvList = app.addEventListener("beforeExport", checkLayer, false);
}
function checkLayer(e){
var listOfLayerNames = ["N-Spacing", "Specification Box", "Dieline", "FPO/Variable Area", "ARTWORK", "Pre-Printed Artwork", "Substrate - for foil/clear plastic", "Technical Details"];
var match = "";
var outOfList = "";
for(var i = 0; i < app.activeDocument.layers.length; i++){
var found = false;
for(var j = 0; j < listOfLayerNames.length; j++){
if(listOfLayerNames[j] == app.activeDocument.layers[i].name){
match += app.activeDocument.layers[i].name+"\n";
found = true;
break;
}
}
if(!found) outOfList += app.activeDocument.layers[i].name+"\n";
}
if(match != ""){
if (!confirm("Unwanted Layers is present:"+"\r"+outOfList)){
e.stopPropagation();
e.preventDefault();
}
}
}

Likes

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 ,
May 28, 2021 May 28, 2021

Copy link to clipboard

Copied

Can you delete preferences of the application.

And restart your application again. Did you try that?

 

Sunil

Likes

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
Explorer ,
May 28, 2021 May 28, 2021

Copy link to clipboard

Copied

Yes, Unfortunately the dailog box keeps on showing whenever I copy a text from Indesign and paste it to other application. I have to correct the issue, the dialog box will pop out whenever I hit the command+v or paste any content from indesign to other apps. 

Likes

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 ,
May 28, 2021 May 28, 2021

Copy link to clipboard

Copied

Hi Joseph,

just tested your script with InDesign 2021 on my German Windows 10 machine.

The good news: Ctrl + C will not invoke the dialog.

Maybe that's an issue on Mac OS only?
Or a specific issue on your personal machine?

Test with other machines. Also under Windows.

 

However, if I rename a layer to e.g. "Dieline", the dialog will come up, but it is not showing the offending layer name, if I try to export a selected rectangle on the page to e.g. JPEG. Answering the dialog with OK will invoke the dialog again, because [object ImportExportEvent] is fired twice.

 

Read out and monitor all property/value pairs of object e, the [object ImportExportEvent] to see, if you find one unique property/value pair in one of the two fired events that are different to find a hook that your function will dismiss the second fired event.

 

Regards,
Uwe Laubender

( ACP )

Likes

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 ,
May 28, 2021 May 28, 2021

Copy link to clipboard

Copied

Forgot: I tested with InDesign 2021 version 16.2.1.102 on Windows 10.

 

What's your version of InDesign? What exact version of Mac OS ?

Is your machine a new one with the M1 chip?

 

Regards,
Uwe Laubender

( ACP )

Likes

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
Explorer ,
May 28, 2021 May 28, 2021

Copy link to clipboard

Copied

We are using Indesign 2021 version 16.1 and Mac BigSur T2 Chip, and we all experienced the same issues when using commant+c

Likes

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 ,
May 28, 2021 May 28, 2021

Copy link to clipboard

Copied

Hi Joseph,

are there other startup scripts running?

 

Regards,
Uwe Laubender

( ACP )

Likes

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
Explorer ,
May 28, 2021 May 28, 2021

Copy link to clipboard

Copied

LATEST

There are only 2 startup scripts that Im currently using,  the other script forces the Indesign file to change the visibility of the layers base on a list that I set within the script.

#target indesign
#targetengine "session"
main();
function main(){
var myBeforeExportEvList = app.addEventListener("beforeExport", checkLayervisibility, false);
}
function checkLayervisibility(e){
var docs = app.documents;
for (var i = docs.length-1; i >= 0; i--) {
if(docs[i].layers.item("N-Spacing").visible == true)
{
docs[i].layers.item("N-Spacing").visible = false;
}
if(docs[i].layers.item("Technical Details").visible == true)
{
docs[i].layers.item("Technical Details").visible = false;
}
if(docs[i].layers.item("Specification Box").visible == false)
{
docs[i].layers.item("Specification Box").visible = true;
}
if(docs[i].layers.item("Dieline").visible == false)
{
docs[i].layers.item("Dieline").visible = true;
}
if(docs[i].layers.item("FPO/Variable Area").visible == false)
{
docs[i].layers.item("FPO/Variable Area").visible = true;
}
if(docs[i].layers.item("ARTWORK").visible == false)
{
docs[i].layers.item("ARTWORK").visible = true;
}
if(docs[i].layers.item("Pre-Printed Artwork").visible == false)
{
docs[i].layers.item("Pre-Printed Artwork").visible = true;
}
if(docs[i].layers.item("Substrate - for foil/clear plastic").visible == false)
{
docs[i].layers.item("Substrate - for foil/clear plastic").visible = true;
}
}
}
alert("Hide Layer is now Activated!"+"\r"+"N-Spacing and Tech Details Layers will automatically be hidden on your next output")
I also have this .txt file.
Short Story:
This file exists solely to force the source code version control
system to create this directory/folder.
 
I dont know if this somehow causes the error

Likes

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