Script to switch module

Hello, is there any way to make script that can change module shown? for example, I can switch between showing xworkspaces module or showing music player module with left click on some icon.