Notifications
Clear all

[Closed] Assign action to keyboard shortcut through script

Is it at all possible to assign an action (macroscript) to a keyboard shortcut through maxscript? And if so, how?
I’ve searched the docs for this, but couldn’t find anything.

46 Replies

I haven’t found a solution for this yet. Anyone got an idea on how to do this?

 JHN

*tumbleweed gently rolls past

I do not know how to directly assign a key to a command but you can do this :-
go to customize user interface assign your keys to the commands then click save and save it as a .kbd file then you can use this command

 actionMan.loadKeyboardFile "my_kbdfile.kbd"

Aha! Does that override all keyboard shortcuts though? So that if I wanted to add a shortcut to my script on someone else’s configuration, I’d mess it all up?

Hmm I guess I could maybe get away with this:

  • Save kbd file, actionMan.saveKeyboardFile
  • Add my own little bit at the end (sounds a bit risky?)
  • Load it back up again, actionMan.loadKeyboardFile

Thoughts?

may be you can parse both the files and check for conflicts because if you open the kbd as .txt you can find lines like these :- 24=15 66 EPoly_Bevel`Editable Polygon Object (this is my own shortcut for bevel = ctrl alt b and you can see 66 its the ascii for B) but you can create your own kbd then compare it with the users line by line and if the numbers in the beginning match theres a conflict…

Yeah I was thinking the same thing.
Do you have any idea what the two numbers in the beginning could be? The 24=15 bit. Maybe that’s the modifier keys? (ctrl, alt, shift)

Two keys that I have assigned (H and V look like this)

40=3 72 toggleOutliner`Outliner 647394
41=3 86 outlinerHideSelectionToggle`Outliner 647394

So that’d be

?=? KeyCode  MacroName  MacroID

i did a little experimentation heres the results :
15 = shift + ctrl
19 = ALT
11 = CTRL
27 = ALT + Ctrl
23 = ALT + Shift
3 = single key thers no combo and the next number represents the ascii
7 = shift

i think max is saving keys in category which are being indexed as array numbers for example i have numbers going from index=SpecialKey Ascii so the first number is an index for a category and the next is the key identifier single keys or combo after that its the ascii of the key

Page 1 / 5