I'm thinking that AppleScript might be the way to handle that, perhaps calling this macro from within it. BlueCactus might have a better approach.