You can call LearnTalents, you don't even need a hardware event for it.
All the issues are from RemoveTalent, which is not only locked to hardware events, but can only be called from blizzard code.
The only calls to the function and made in the StaticPopup handlers in
Blizzard_TalentUI.lua, trigged in PlayerTalentFrameTalent_OnClick, only called by the OnClick handler for PlayerTalentButtonTemplate in
Blizzard_TalentUI.xml.
The talent UI needs to be loaded though a hardware event to avoid taint, the easiest way to do that is to toggle the frame though a double /click TalentMicroButton.
Eventually you'll end up with something like this:
Code:
/stopmacro [combat]
/click TalentMicroButton
/click TalentMicroButton
/click PlayerTalentFrameTalentsTalentRowXTalentY -- talent you want to learn (row/col)
/click StaticPopup1Button1 -- should probaly had some checking for which popup is actually the talent one.
/click PlayerTalentFrameTalentsTalentRowXTalentY -- repeat as needed....
/click StaticPopup1Button1
...
/run LearnTalents(a,b,c,d,e,...) -- will need to be a slightly delayed call to give the server time to process the unlearns