You can try a /click macro, perhaps. Or you can use something like PAB to track your cooldowns. But there is no way for a macro to judge an if/then condition for buffs or the like.