Macro /cast Engineering doesn't work

Using basic /cast Engineering does not work. I wrote an overly complicated fix by using the WoW LUA API, but very few players would be able to do this. My solution is below, though we shouldn’t have to do this. Glad I could make it work though.

#showtooltip [mod:shift]Thermal Anvil;Engineering
/summonpet [mod:shift]Alvin the Anvil
/run s=IsShiftKeyDown(); if s==false then C_TradeSkillUI.OpenTradeSkill(202) end

Opens the engineering ui just fine for me.

Works for me too, until I add conditionals, like having a one button macro to both open skill and summon Anvil pet

This also isn’t working for me. I can use /run C_TradeSkillUI.OpenTradeSkill(202) however that can only open the window, not close it.