Can’t change some menu shortcuts

  • I wanted to remove all menu shortcuts but apparently some are not added to the preferences yet. It's not possible to change them using a script either:

    ('Edit', 'Select All')
    ('Edit', 'Copy As Component')
    ('Edit', 'Paste in Layer')
    ('Python', 'Show Log File')
    ('Python', 'Jump Back')
    ('Window', 'Minimize')
    ('Window', 'New Space Center')
    ('Window', 'Zoom in A Bit')
    ('Window', 'Zoom out A Bit')
    ('Help', 'Application Help')

    Sorry for nitpicking, but I need to remove them for a tool that its shortcuts can conflict with them.

  • admin

    I would advise to take a different route... :)

    Prepolator and MetricsMachine extensions have their own shortcuts with an option to overwrite the existing shortcuts. There are just not enough modifiers and keys...

    an example:

    subscribe when your tool/window becomes active and unsubscribe when it deactivates!

    import AppKit
    _specialCases = [
        ("w", AppKit.NSCommandKeyMask),  # close window, dont subscribe afterwards
        ("`", AppKit.NSCommandKeyMask),  # jump to next window, dont subscribe afterwards
        ("`", AppKit.NSCommandKeyMask | AppKit.NSShiftKeyMask),  # jump to prev window, don't subscribe afterwards
    class KeyEventMonitor(object):
        def __init__(self):
            self.monitor = None
        def subscribe(self):
            self.monitor = AppKit.NSEvent.addLocalMonitorForEventsMatchingMask_handler_(AppKit.NSKeyDownMask, self.eventHandler)
        def unsubscribe(self):
            if self.monitor is not None:
            self.monitor = None
        def eventHandler(self, event):
            inputKey = event.charactersIgnoringModifiers()
            eventModifiers = event.modifierFlags()
            # check if inputKey and eventModifiers match with your shortcuts
            found = True
            if inputKey = "s" and eventModifiers & AppKit.NSCommandKeyMask:
                # overwrite cmd s
                found = False
            if not found:
                if (inputKey, eventModifiers) not in _specialCases:
                    # don't resubscribe when the window is closed

  • I didn't think of that! Thank you, Frederik. This is very interesting.