This has commands for mounting and unmounting (assuming the old TrueCrypt command line args still work with VeraCrypt):
If those work as individual buttons, you can probably use @ifexists to make them into a single toggle button:
@ifexists:X:\
< unmount command here >
@ifexists:else
< mount command here >
But I'd make sure they work individually first so it's easier to work out where things are going wrong if they don't work. In fact, I'd get the commands correct and working in a Command Prompt first, before involving Opus as all.
There isn't a good/reliable way to make a button's visual state depend on whether a drive is mounted, at least that I can think of.
You could do it using variables but then the indicator would go wrong if the variable got out of sync (e.g. if the drive was mounted or unmounted via another method, e.g. shutting down the PC).
I'm glad that the VeraCrypt command lines are working for you. In case you may not have noticed, you should close the Directory Opus window before you execute the VeraCrypt button commands; else you may receive a VeraCrypt error.
I have my VeraCrypt buttons placed on the Directory Opus tray icon; or you could place them on a floating toolbar.
Also, you can dismount VeraCrypt drives by right-clicking the VeraCrypt tray icon; which will trigger a Windows notification. The VeraCrypt command lines circumvent the Windows notifications.
Leo, I appreciate your suggestion for the CloseAllTabs script; I tried it and it seemed to help. I decided to experiment, and uninstalled the CloseAllTabs script, then tried running a VeraCrypt command button -- it worked while Directory Opus was open! It was a good surprise for me. I don't remember how long ago I began relying on my workaround; or if it were caused by DOpus or VerCrypt; but habits often take hold.
I provided some initial help and ended up getting helped myself. Thanks.