I tested the code you provided and all three buttons work for me. The left and right buttons even work in combat, but the middle button does not. I used a piece of a weakaura I have for the button.
Lua Code:
local proPlugin=CreateFrame("Button","proPlugin",UIParent,"ActionButtonTemplate,SecureActionButtonTemplate")
proPlugin:SetSize(32,32)
proPlugin.icon:SetTexture(135912)
proPlugin:SetPoint("CENTER")
proPlugin:EnableMouse(true)
proPlugin:SetScript("OnMouseDown",function(self, button)
local prof1, prof2, _, _, _ = GetProfessions()
if button == "LeftButton" then
if prof1 then
CastSpellByName((GetProfessionInfo(prof1)))
else
print('|cff33ff99BasicUI:|r |cffFF0000No Profession Found!|r')
end
elseif button == 'MiddleButton' then
ToggleSpellBook(BOOKTYPE_PROFESSION)
elseif button == "RightButton" then
if prof2 then
CastSpellByName((GetProfessionInfo(prof2)))
else
print('|cff33ff99BasicUI:|r |cffFF0000No Profession Found!|r')
end
end
end)