local binds, keys, command = {}, {}
for i = 1, GetNumBindings() do
binds[i] = {GetBindInfo(i)}
if #binds[i] > 2 then
for k, v in ipairs(binds[i]) do
if k = 1 then
command = v
elseif k = 2 then
else
keys[v] = command
end
end
The keys table here maps the key values to the command (the native data is mapped the other way around - commands to key values).
The commands you’re going to be interested in are the ones that are button names.
Button names are things like ACTIONBUTTON1 and MULTIACTIONBAR1BUTTON3.
What’s missing is a map between the button names and the action slots.
Blizzard’s native system is an unbelievable mess in this regards.
That paging bar nonsense mucks up the mapping from action slot to action button terribly.
So the action that’s on a button NOW might not be the action on that button when you change bar paging.
However, for those buttons that are NOT on paging bars you would want to poll the action slot that corresponds to that button and capture the spell that’s there.
Understand, not everything on an action button is a spell. Mounts, pets, toys, items, macros, flyouts all get handled differently so as you build your data for this, you’ll need to know how you want to deal with each.
Some of them aren’t very well documented (some aren’t documented at all).
Essentially, though, you’d want to take the action slots and spin through them and build a table by action slot of what spell is there (assuming we’re talking just spells).
So, ACTIONBUTTON1 assigned to ACTIONSLOT1 has Bunny Fling on it (at least until you swap paging bars).
You know ACTIONBUTTON1 is bound to your 7 key (for example) from the keys table above.
From here, it’s just a matter of creating a cross-reference between the spells in the action slots with the keys for the action buttons - assuming you can map action slots to action buttons at all (very complicated for vanilla, simpler for ElvUI, Bartender, Dominos).