[Script] Want to do a menu action with "Action.perform()" method


I want to do a : “Scene / Camera / Camera” menu selection in a script. Can I achieve that with the Action.perform() method, and what’s the input action name?

Otherwise, what are the actions available with this method?

And if it’s not possible with this method, is there any other method, to do that with scripting?




this sounds interesting, but I’m not exactly sure what you’re saying. As an experiment, I tried replacing the slot “onActionUndo()” with the name of my custom script, “TogglePrefix()”. When I pressed Ctrl-Z, SBPro still ran undo. Did I do that wrong? Or does this only work in Harmony?

Bump for interest!

It’s very frustrating that the reference doesn’t provide any way to perform any action.

Hey !

Sorry I said it was possible but I didn’t explain anything.
First I recommend you to backup your current “shortcut.xml” by renaming it. I recommend you also to comment or delete the line that uses the shortcut you want to overwrite. Then this is the line you have to write in the view you want your script to be able to run (camera, timeline, general,…) :

shortcut checkable=“false” id=“ShortcutTest” itemParameter=“NameOfYourFunctionToCall in nameOfYourScript.js” longDesc=“descriptionOfYourScript"responder=“scriptResponder"slot=“onActionExecuteScript(QString)” text=“short Description” value=”+”


The Id must be different of all the others. the item parameter must be "NameOfYourFunctionToCall in nameOfYourScript.js ", the responder must be “scriptResponder” and the slot must be something that will trigger the script, so has to be “onActionExecuteScript(QString)”. then in value, put the shortcut you want to use.

Save it and open Harmony (or SBP) and your shortcut must perform like a charm.

Note that you have to have your script “installed” I mean imported in your script bar in order it to be triggered properly.
I’ll probably open a new topic specially for that soon in order to explain it more carefully.
Hope It’ll help.

Let me know.

Same here!
I’m a very newbie to Toon Boom Harmony but Harmony script document is not enough.

Hey Toon Boom team, is there any chance for us to access to the list of that actions name strings in the near future?


I achieved to do that in the past and it had been a lot of search.
I’m not currently with my computer, I will be able to check that in a couple of days.

Therefore, I think you can access all these actions by opening the “menu.xml” (located in the installation folder)l in a text editor and search for the word “camera”. I’m pretty sure there is the line with the proper call method.

Anyway, I’ll let you inform when I will get back home in few days.

Whoa, this is huge!
Thank you for the info, eAthis!

I checked that xml file and yep, it’s there. On Win, the location is “C\Program Files\Toon Boom Animation\Toon Boom Harmony 15.0 Premium\resouces” just in case.
I want these kind of information more about scripting.

Your welcome !

Everything you need to know about performing action is in there. By modifying the shortcut.xml you can also launch script with shortcuts. For example the create new drawing (read node) in the node view, I replace it but one of mine that create a drawing with the input put in uppercase, then it changes some properties like I need, and then create a peg with same name + suffix and connect it to the read mode. It doesn’t look like very much work if you do it manually, but it truly saves a LOT of time !

Happy it helped by the way !

please excuse any stupid mistakes I’m making - I’m familiar with javascript and not much else!
The script is a function called TogglePrefix() in TogglePrefix.js, sitting in the 14200-scripts directory. It renames the selected layer and all layers in the scene with the same name by adding a prefix to them. I’ve imported the script to the toolbar, and placed the following code into shortcuts.xml’s “General” section:

shortcut checkable=“false” id=“TogglePrefix” itemParameter=“TogglePrefix in TogglePrefix.js” longDesc=“Toggle Prefix” responder=“scriptResponder” slot=“onActionExecuteScript(QString)” text=“Toggle Prefix” value=“Ctrl+J”

Nothing happens when I press Ctrl+J, though. What am I messing up? Also, what’s a script responder?

Hey !

Seems that what you did is great. I didn’t have SBP so I downloaded the trial version and tried to do it but unfortunately seems that it’s not the same way as in Harmony. I did a short script with you function and script name and it works like a charm in Harmony.

I think we need someone from the official team here. But maybe it’s not possible yet.

I’m sorry.


I tried the method and worked here…

Did you try to set the shortcut inside Harmony?

If you go preferences, you might see in the menu that you assigned the line. I did it under Network so it shows in the NodeView tab options.

I think assigning the shortcut inside the “shortcuts.xml” might not be the best way, once many of them can be duplicated. And Harmony reads the file from top to bottom.

So if CTRL+J is defined again in the bottom some where, it would be replaced.