Other possible solution for automatic profile switching:
You can use the Chrome or Firefox command line to start it with a certain profile: command line - How do I start Chrome using a specified "user profile"? - Super User
and then start the macro via the UIvision command line API.