(wow classic) Open and close a NPC window with macro?

Hello all

I am looking for a makro to open and close a NPC window.

My goal: I would like to buy a rnd item by macro … so I have to target the NPC, open the window, buy the item and close the window (to close the window is important as well).

Could you please help me in that case. Thank you very much.