Minecraft has a gamemode switching feature, if you press f3 and f4 together.

To make an Aristois macro you'd need to assign each command (/gamemode X) to a key