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

Script to autoload Question.

Advisor ,
May 18, 2016 May 18, 2016

Is there a way to get my Script to autoload and be placed in the menu's where the plugin's are found? maybe right before the help menu.  I have a markzware plugin that is in the menu's and i just click on that and go from there.  It would be nice to have this script up there too.  Is there a way to make this happen?

TOPICS
Scripting
895
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 1 Correct answer

Guide , May 18, 2016 May 18, 2016

example:

var 

  myEventListener = app.eventListeners.item("xx"); 

 

  if (!myEventListener.isValid) { 

  myEventListener = app.addEventListener( "onInvoke", doJob ); 

  myEventListener.name = "xx"; 

  } 

 

function doJob() { 

  //your main function

}

Translate
Advisor ,
May 18, 2016 May 18, 2016

I should say is there a easy way where i'm not going to have to remake this script all together.

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
Advisor ,
May 18, 2016 May 18, 2016

I found this if there is a newer way let me know.  I may have questions if this gives me errors.

//=============================Script Start =============================//

var mySampleScriptAction = app.scriptMenuActions.add("First Script");

var myEventListener = mySampleScriptAction.eventListeners.add("onInvoke", function(){alert("This menu item was added by a script.");});

//If the submenu "Script Menu Action" does not already exist, create it.

try{

    var mySampleScriptMenu = app.menus.item("$ID/Main").submenus.item("NewMenu");

    mySampleScriptMenu.title;

}

catch (myError){

    var mySampleScriptMenu = app.menus.item("$ID/Main").submenus.add("New Menu");

}

var mySampleScriptMenuItem = mySampleScriptMenu.menuItems.add(mySampleScriptAction);

//============================== Script End ===============================//

Thanks & Regards

T.R.Harihara Sudhan

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
Advisor ,
May 18, 2016 May 18, 2016

Ok this does put a menu where i'm wanting but i cannot see where to place my script.  Any ideas?

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
Guide ,
May 18, 2016 May 18, 2016

just add this on top of your main 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
Guide ,
May 18, 2016 May 18, 2016

example:

var 

  myEventListener = app.eventListeners.item("xx"); 

 

  if (!myEventListener.isValid) { 

  myEventListener = app.addEventListener( "onInvoke", doJob ); 

  myEventListener.name = "xx"; 

  } 

 

function doJob() { 

  //your main function

}

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
Advisor ,
May 18, 2016 May 18, 2016

Oh i see what i was doping wrong.  I was placing my script after the last }  ..  Thank you..

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
Advisor ,
May 18, 2016 May 18, 2016

One more thing.  I cannot seem to get rid of the other 2 menu's this placed up on my menu bar.

Screen Shot 2016-05-18 at 3.38.43 PM.png

I checked to see if i had any test scripts still running but i do not.

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
Advisor ,
May 18, 2016 May 18, 2016

Never mind after i worded it different i found it. The below script worked.

try {
  app.menus.item("$ID/Main").submenus.item("New Menu").remove();
}catch(e){}
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, 2016 May 19, 2016

Never mind after i worded it different i found it. The below script worked.

Be very careful with removing menus or submenus.

Some years ago when I experimented with that I ruined my InDesign installation completely by removing the wrong menu.

Even after reinstalling I had some problems so I had to to use the cleaner tools to get rid of all entries somewhere in my system and install again.

Uwe

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
Advisor ,
May 20, 2016 May 20, 2016

I was very careful to only delete those two menu's.  I am way to afraid to play around with that 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
Community Expert ,
May 23, 2016 May 23, 2016

The safe way to do this is to delete your preferences on start-up: Press (the Mac equivalent) of Shift+Ctrl+Alt when you start Indesign, and when it asks you if you want to delete the prefeences, answer yes.

Peter

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
Advisor ,
May 23, 2016 May 23, 2016

Ok I didnt think that would work because it was a script that i used that added those menu's.  So my thinking was the Reseting Preferences would not remove the unused script menu's

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 23, 2016 May 23, 2016
LATEST

You should have tried

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