Thanks for all the help and explanations
After a lot of experimentation around semlar's code, I technically have a button that switches one talent for me every time I press it. I haven't gotten around to trying to make it work for several talents yet, but here's the code I have so far, in case somebody finds it useful:
Lua Code:
function pickTalent(row,col)
local s = [[
/stopmacro [combat]
/click PlayerTalentFrameTalentsTalentRow%sTalent%s
/click StaticPopup1Button1
]]
return s:format(row,col)
end
f.btn = CreateFrame ("Button", nil, f, 'SecureActionButtonTemplate, SecureHandlerBaseTemplate')
f.btn:RegisterForClicks ("AnyDown")
f.btn:SetAttribute ("type","macro")
f.btn:SetAttribute ('macrotext', pickTalent(1,2))
f.btn:SetScript ('PostClick', function()
C_Timer.After(1, function ()
PlayerTalentFrameTalentsLearnButton:GetScript("OnClick")(PlayerTalentFrameTalentsLearnButton)
end)
end)