You can do that with the Messenger Lock feature. You don't need a script to do that.
Simply go to Plus! > Preferences > Messenger > Messenger Lock
Click here for screenshot
There you can change the settings, etc.
By default, you just press CTRL+Space on your keyboard to lock Messenger, which will hide everything and change the icon in the systray (bottom-right). Then double-click the icon to restore.