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

Disable a startup script

Explorer ,
May 17, 2021 May 17, 2021

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
1.6K
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

correct answers 2 Correct answers

Community Expert , 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. 

Translate
Community Expert , 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
...
Translate
Community Expert ,
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. 

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 ,
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(){
    alert("Add listeners here and run script")
};

 

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

thank you @brian_p_dts @rob day 

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

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

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

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

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

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

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

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

 

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