Close a dock when opening another - detect when a dock is open?

Unfortunately, I don't think you can achieve this using the dock handle.