Shortcut to switch between application in an application group

I would like,to have one shortcut that activates the next application in a group.

For example, ctrl-shift-a would activate chrome, then, if there are no more instances of chrome, it would activate an instance of safari and then firefox.

Same for iMessage\Mail and so forth.

Is there a way to achieve this?

Sure, just use an appropriate sequence of conditionals (If Then Else). Something like this:

You may have trouble detecting different "instances" of Google Chrome if you have more than one of them running.

Cool. Thanks!
This is what I did to switch between messages and mail for the same shortcut: