Get customized macros or keyboard shortcuts programmatically

I try to pull my cunstomizations with a script ( s. the code below), but this returns only the default settings.
Is it even possible? For aliases this is easily done with rs.AliasNames()

I tend to forget my settings when I pause using Rhino for some time.

import Rhino
for i in range(0,2000):
    a = Rhino.ApplicationSettings.ShortcutKeySettings.GetMacro(Rhino.ApplicationSettings.ShortcutKey(i))
    k = Rhino.ApplicationSettings.ShortcutKey(i)
    if a:
        print(i, a, k)

Hi @jackshaftoe,

Does this work any better?

import clr
import Rhino
import System

shortcut_type = clr.GetClrType(Rhino.ApplicationSettings.ShortcutKey)
for shortcut in System.Enum.GetValues(shortcut_type):    
    macro = Rhino.ApplicationSettings.ShortcutKeySettings.GetMacro(shortcut)
    if not macro: macro = '<none>'
    print('{0} : {1}'.format(shortcut, macro))

– Dale

Hi @dale,
same result, 59 macros both ways. But good to learn about the clr module.

Here is the source code - perhaps this helps?

– Dale

Thanks @dale,
I already figured that and probably wasn’t precise enough.
I have customizations in
1: Preferences → Aliases. Ich already got that with running rs.AliasNames(). I set-diff the
result of that method against a list of default aliases and voilá, get my custom ones. Problem solved.

2:Preferences → Commands → Customize… → Command Editor. In the macro library, one can set
a.: custom keyboard shortcuts, you can see them afterwards in keyboard shortcuts tab of the command editor, even copy them to clipboard.
b.: add custom macros to the macro library.

2a & 2b is what I’m trying to get. I have tried

  • ShortcutKeySettings.GetMacro(ShortcutKey)
  • Rhino.Commands.Command.GetCommandNames(True, True)
    but only got defaults, not my commands.

I think, I bugged you enough, thanks for effords.