You can do some conditional processing (i.e.: nodead, harm, nochanneling, etc.) in macros and some UI mods will operate on conditionals (but only out of combat). To stop the macro when either the GCD is down or the spell is on cooldown is not possible within a macro.