ID 590727 - Setting a shortcut on the createCompSpecial action doesn't work, when running the code from .nuke/Python/Startup

Follow

Problem summary
Setting a shortcut on the createCompSpecial action doesn't work, when running the code from .nuke/Python/Startup.
The same code does work when running it from Nuke Studio's Script Editor instead.
 
Customer reported version
Nuke Studio 15.1v4
 
Customer reported platform
Windows 10
 
Steps to reproduce
 
1) Save the following code in a Python (.py) file in your .nuke/Python/Startup directory:

from hiero.ui import findMenuAction, registeredActions from PySide2 import QtGui MenuItem = findMenuAction('foundry.timeline.comp.createCompSpecial')MenuItem.setShortcut(QtGui.QKeySequence('Alt+Shift+C'))
 
2) Launch Nuke Studio.
 
Expected behaviour
This code should set a Alt+Shift+C hotkey for Create Comp Special. 
 
Actual behaviour
You will see errors, like the following, printed to the command line window:
ERROR:Hiero:Plugin C:/Users/<username>/.nuke\Python\Startup\hotkeys.py could not be loaded: 'NoneType' object has no attribute 'setShortcut'Traceback (most recent call last):  File "C:\Program Files\Nuke15.1v4\pythonextensions\site-packages\hiero\core\find_plugins.py", line 42, in loadPluginsFromFolder    module = nuke_internal.loadModuleFromPath( moduleName, p )  File "C:\Program Files/Nuke15.1v4/plugins\nuke_internal\utils.py", line 36, in loadModuleFromPath    spec.loader.exec_module(mod)  File "<frozen importlib._bootstrap_external>", line 883, in exec_module  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed  File "C:/Users/ThomasRoberts/.nuke\Python\Startup\hotkeys.py", line 5, in <module>    MenuItem.setShortcut(QtGui.QKeySequence('Alt+Shift+C'))AttributeError: 'NoneType' object has no attribute 'setShortcut'
 
Workaround
Calling setShortcut on a kAfterNewProjectCreated event will delay the function from being run until Nuke Studio's GUI has opened:
from hiero.ui import findMenuAction, registeredActions from PySide2 import QtGui from hiero.core import eventsdef setCreateCompSpecialHotkey(event):	MenuItem = findMenuAction('foundry.timeline.comp.createCompSpecial')	MenuItem.setShortcut(QtGui.QKeySequence('Alt+Shift+C'))events.registerInterest(events.EventType.kAfterNewProjectCreated, setCreateCompSpecialHotkey)
 
Reproduced by support
This bug has been reproduced in:
Nuke Studio 15.1v4 - Windows 11 - macOS 12
Nuke Studio 12.0v1 - Windows 11 - macOS 12
 
Earliest version tested
Nuke Studio 12.0v1 
- This issue appears to be in all tested versions of the product
 
For Nuke 12, this needed to tested with the following code. The same issue occurs though:
from hiero.ui import findMenuAction, registeredActions from PySide2 import QtGui MenuItem = findMenuAction('foundry.timeline.effect.createCompSpecial')MenuItem.setShortcut(QtGui.QKeySequence('Alt+Shift+C'))
 

    We're sorry to hear that

    Please tell us why