Harmony: Keyboard Shortcuts

To modify the existing shortcuts in Toon Boom Harmony; you can go Edit => Preferences, find the Shortcuts tab and expand any of the groups to edit the key trigger for the relevant shortcut. You can find more information on using shortcuts here: < https://docs.toonboom.com/help/harmony-16/premium/preferences-guide/shortcut-preference.html>, and a list of the existing shortcuts for Harmony 16 here: < https://docs.toonboom.com/help/harmony-16/premium/keyboard-shortcuts/general-keyboard-shortcut.html  >


Custom Shortcut Functionality


If you want to create a custom keyboard shortcut for a command that does not already exist in the shortcuts menu, the method it a bit more complicated but it is still possible.


1. You need to create a script  that executes the command you want the shortcut to execute.

2. You need to edit the shortcuts file so that it includes a reference to the script you created.


1. Creating Executable Script

I will create a simple script that writes a message to the Message Log window whenever it is called. I am working on Harmony Standalone and so saved it to my User location.

If you create a new script in the Script Editor window of Harmony, it will save the created file in your AppData folder, the path will look something like this : 

< C:\Users\*YOUR USERNAME*\AppData\Roaming\Toon Boom Animation\Toon Boom Harmony Premium\1600-scripts > 

Harmony can will also populate the Script Editor library with any javascript files that are in the Harmony program files scripts location:

< C:\Program Files (x86)\Toon Boom Animation\Toon Boom Harmony 16.0 Premium\resources\scripts >




The file is called CC_shortcutExample.js and only contains the function shortcutExample which looks like:


function shortcutExample()
{
MessageLog.trace("shortcut example message")
}

After saving, I then added shortcutExample  as a button in my Scripting toolbar to test that the script was working as expected.



Once the function is working correctly, you can customise the shortcuts file to include your new function as an option,





2. Editing Shortcuts File

The Toon Boom Harmony 16 shortcuts file is located in its resources folder:
< C:\Program Files (x86)\Toon Boom Animation\Toon Boom Harmony 16.0 Premium\resources >





You will need admin priveleges on the machine to overwrite this file so it is best to make a copy of it that we will edit before we overwrite the master.

I copied onto my desktop, and then created an additional copy named "shortcuts_backup" which I will not edit.



Open the shortcuts.xml file in a text editor. To get the syntax highlighting ( different colours for different words ) you can use Visual Studio Code ( which is free ) or google app scripts ( web based, also free ) and I'm sure many others but they were the first I used and they are fine.

I then edited the shortcuts.xml file to include a new category "My Custom Shortcuts" and in that category I created a shortcut entry for my "shortcutExample" script.



I have copied out lines 7 - 10 here:

// my custom shortcuts

<category id="myCustomShortcuts" text="My Custom Shortcuts" >

<shortcut checkable="false" id="custom_01" itemParameter="shortcutExample in CC_shortcutExample.js" 
    longDesc="Execute the shortcutExample script" responder="scriptResponder" 
        slot="onActionExecuteScript(QString)" text="text for shortcutExample"  value=""/>

</category>

Now overwrite the original shortcuts file with this new edited one ( make sure all instances of Toon Boom Harmony are closed )

When you open Harmony again you will see your custom shortcut as an entry in the Edit => Preferences => Shortcuts menu, and can assign it to a shortcut key like any other shortcut option.



Make sure to check the message log to make sure that your function is still working as expected.


3. Relevant Locations:

The file that you need to modify to make custom shortcuts possible is:  

C:\Program Files (x86)\Toon Boom Animation\Toon Boom Harmony 16.0 Premium\resources\shortcuts.xml

To map the shortcut actions to different key-presses you need to modify:   

( Local ) C:\Users\chrisc\AppData\Roaming\Toon Boom Animation\Toon Boom Harmony Premium\full-1600-pref\Shortcuts.xml
( Server ) ...\USA_DB\users\chrisc\Harmony Premium\full-1600-pref\Shortcuts.xml


The custom script files that Harmony will look for custom actions in is: 

( Local ) C:\Users\chrisc\AppData\Roaming\Toon Boom Animation\Toon Boom Harmony Premium\1600-scripts
( Server ) ...\USA_DB\scripts

2 comments:

  1. For anyone trying to do this on version 15 on a Mac, the file you're looking for is /Applications/Toon Boom Harmony 15.0 Premium/tba/resources/shortcuts.xml

    It's probably in the same place for version 16 (but with the version number changed in the file path, of course).

    ReplyDelete
  2. I tried this in TB 20, but didn't work. Do you know if it is possible?

    ReplyDelete