Check if the image is in closed mode before open it, use Elements exist activity to check that and if it is true then we have to open by next activity.
You can check image/element if it is open or close before the next automation. Another possible solution is to verify an image/element that only appears with the button open.
I recommend trying to use keyboard shortcuts if they exist to open / close the button.
An element exist, saving as “cabecera” when image is close.
then, in the IF condition, when “cabecera” is false (open image), I’ve set a click on image for close it.
works, but with a considerly delay (5 seconds aprox.)