Notifications
Clear all

[Closed] Assign action to keyboard shortcut through script

Ok, so the modifier keys are done by bitwise OR, that’s nice

none  =  3 = 00011
shift =  7 = 00111
ctrl  = 11 = 01011
alt   = 19 = 10011

Thanks for your help!

yep i think now it can be parsed using maxscript … Cheers

Indeed. macro IDs can be found through macros.list(), although that is rather a tedious procedure.
The array index is still a bit confusing to me though…

edit: hang on, macro IDs? It’s not the macro ID that comes after the macro name… must be something else?

the index numbers seam to change when the number on the extreme right changes

*edit: i think this number is related to items in the group list box in the customize user interface > keyboard panel because all my pflow hot keys share the same number

1 Reply
(@pjanssen)
Joined: 1 year ago

Posts: 0

Looks like you’re right again!
What number do your Main UI shortcuts have? Mine all have 647394 or 0 (for lowlevel actions?). I wonder if this is the same for everyone.

 JHN

A macroscript generates an idea in the order of lastMacro + 1, so these numbers are not global like classId’s and differ from system to system. So referencing these indeed requires to parse the macros.

maybe this helps:


ss = stringStream ""
macros.list to:ss
seek ss 0

while (not eof ss) do
(
	local l = readLine ss
	if matchPattern l pattern:"*Outliner*" do
	(
		format "id:%, name:%
" (filterstring l " ")[1] (filterstring l " ")[2]
	)
)

-Johan

Yeah I was aware of the macro IDs not being the same on each system. The number that should be in the keyboard file (luckily?) isn’t the macro ID. It would appear to indicate the shortcut group as HornBerger indicated.
Question is though: how to make sure that the correct value is written?

firstly theres 1 disturbing feature of these keyboard shortcuts try this out open the customize ui > keyboard panel and type “6” in the Hotkey text field it shows its not assigned to any key … but when you change the group panel to pflow its shows its assigned to the particle view toggle also the pflow toggle works only with the overide toggle on :S (i cudnt have figured that 1 had it not been for johan’s post in the previous thread) possibly its only searching for the hot keys in 1 particular category i.e the main ui

yea mine too example :- 32=15 73 EPoly_IgnoreBack_Toggle`Editable Polygon Object 647394

i think internally max is either assigning a particular id to the list box items (that would be weird) or these are handles to the main categories like main ui and pflow etc

 JHN

Ah I see… well, it’s like this with some many OS an UI related stuff, just when you think you’re there, it’s just one little detail missing that max will not reveal. I remember jumping through many hoops trying to build a flexible and automatic menu system for my scripts.

-Johan

alright i find this number 647394 in the modulartoolbarsui file as well,

Item0=2|0|0|31|4|647394|namedSelSets`Edit|0|0|"Edit Named Selection Sets"||0|enss_maintoolbar

and in many more places in the file i think this number represents a handle to a location where you can add your own tool bars … its being used by every tool bar i have in max (o btw the modulartoolbarui file is located in c:\program files\autodesk\3d max 2010\ui. for me)

So it looks like it’d be fairly safe to add shortcuts this way:

  • Parse the keyboard file, look for the last entry with “handle” 647394, find its index.
  • Find any occurrences of mod_key_bits key that you want to store, remove them (?)
  • Add a new line:
(last_index + 1)=mod_key_bits key macro_name`macro_category 647394

I’ll write some functions to handle this, and see if that works.

Page 2 / 5