The latest update of Keyboard Maestro allows you to make a tiny screendump of an icon, check whether that icon is on the screen, click it if it's there, and branch off to choose a menu item and so on if it isn't.
(You would also need a snippet of Applescript, to be run by Keyboard Maestro, to check whether any shapes were selected before proceeding).