[Closed] Assign action to keyboard shortcut through script
A small note on using the default keyboard file:
It is possible that the file to which actionMan.getKeyboardFile() points, doesn’t exist. With a fresh installation of 3dsmax for example.
Although the script catches this when trying to open it (well, still throws an error, but it’s not terrible), you should keep it in mind. It might be useful to include a function like this in the struct:
function getDefaultKeyboardFile =
(
local kbd_file = actionMan.getKeyboardFile();
if (getFileSize kbd_file == 0) do
actionMan.saveKeyboardFile kbd_file;
kbd_file;
),
1 more for the book of wisdom i think this is the after effects of the reinstall you had to do to fix the cui.registerdialogbar”???” problem
Thanks for all the hard work on this. But one other thing that would be really useful would be a function to return the shortcut key for a given macroscript. That way we could add a tooltip or additional text to macro button telling the user what the shortcut is.
I’m going to try and parse the code you guys have already posted and see if I can figure out how to do that.
fn getKeyMacroKBD name category file: =
(
local pattern = "* " + name + "`" + category + " 647394"
local hots = #()
if file == unsupplied do file = actionMan.getKeyboardFile()
if (ss = openfile file) != undefined do
(
while not eof ss do
(
str = readline ss
sss = filterstring str "= "
k = sss[2] as integer
c = sss[3] as integer
i = sss[sss.count] as integer
if matchpattern str pattern:pattern do
(
ch = toUpper (bit.intaschar c)
if bit.get k 5 do ch = "ALT+" + ch
if bit.get k 4 do ch = "CTRL+" + ch
if bit.get k 3 do ch = "SHIFT+" + ch
append hots ch
)
)
close ss
)
hots
)
returns all hot_keys as array of strings.
Enjoy!