Disable a startup script

Explorer ,
May 17, 2021 May 17, 2021

Copy link to clipboard

Copied

Hello guys, I need help on my startup script. Is there a way to disable a script without removing the script file? I dont want to disable it permanently, just like a switch button to enable and disable a startup script. Thank you in advance

TOPICS
How to, Scripting

Views

286

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

correct answers 2 Correct Answers

Adobe Community Professional , May 17, 2021 May 17, 2021
Startup scripts, by their nature, run at startup. If you don't want the script to run at startup, just put it in your regular scripts folder and run it when you want to. Or you can include Event Listeners in the startup script to trigger or not based on desired functionality. Really depends on the script and what you're trying to enable or disable. 

Likes

Translate

Translate
Adobe Community Professional , May 18, 2021 May 18, 2021
Maybe something like this: var isRun; var theDialog = app.dialogs.add({name:"Startup", canCancel:true}); with(theDialog){ with(dialogColumns.add()){ staticTexts.add({staticLabel:"Run Script:"}); with(dialogColumns.add()){ isRun = checkboxControls.add({checkedState:false, minWidth:150}); } } } if(theDialog.show()){ if (isRun = isRun.checkedState) { main() }else{ theDialog.destroy(); } } function main(){ a...

Likes

Translate

Translate
Adobe Community Professional ,
May 17, 2021 May 17, 2021

Copy link to clipboard

Copied

Startup scripts, by their nature, run at startup. If you don't want the script to run at startup, just put it in your regular scripts folder and run it when you want to. Or you can include Event Listeners in the startup script to trigger or not based on desired functionality. Really depends on the script and what you're trying to enable or disable. 

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

Copy link to clipboard

Copied

Maybe something like this:

 

var isRun;
var theDialog = app.dialogs.add({name:"Startup", canCancel:true});
with(theDialog){
    with(dialogColumns.add()){
        staticTexts.add({staticLabel:"Run Script:"});             
        with(dialogColumns.add()){
            isRun = checkboxControls.add({checkedState:false, minWidth:150});
        }
    }
}
if(theDialog.show()){
    if (isRun = isRun.checkedState) {
        main()
    }else{
        theDialog.destroy();
    }
}


function main(){
    alert("Add listeners here and run script")
};

 

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

Copy link to clipboard

Copied

thank you @brianp311 @rob day 

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

Copy link to clipboard

Copied

If I want to disable this layer "DETECT_UNWANTED LAYERS". How can I execute it with the code youve provided?

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

Copy link to clipboard

Copied

Is the name of the layer you want to disable DETECT_UNWANTED LAYERS? Do you want to hide, lock or delete the layer?

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

Copy link to clipboard

Copied

thats the name of the startup script. What it does is, it will always show all unwanted layers on the document once you export the file to pdf. However, Im using another script which is the batch_convert where it can export a number of outputs base on the opened documents in Indesign. The minor problem is, DETECT_UNWANTED LAYERS.jsx will always be triggered everytime Indesign will export pdf, in this case the batch_convert.jsx.

 

Thats why I want to temporarily disable DETECT_UNWANTED LAYERS.jsx without totally removing the script file, so I can run batch_convert.jsx without all the dialoge popping up

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

Copy link to clipboard

Copied

Have you tried supressing dialogs in the batch_convert.jsx script—set the user interaction at the begining and end of the script:

 

app.scriptPreferences.userInteractionLevel = UserInteractionLevels.NEVER_INTERACT;
//code to run
app.scriptPreferences.userInteractionLevel = UserInteractionLevels.INTERACT_WITH_ALL;

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

Copy link to clipboard

Copied

LATEST

Hi Joseph Christian,

another option would be a text file that contains the names of all startup scripts.

Every startup script will first read the contents of that text file and look after its own name.

If the name of the startup script is found it will start.

 

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