Detect when user click on a button of the toolbar

I created a button integrated into the msfs toolbar.
When pressed, nothing deliberately opens but that’s okay, that’s what I want.
How can I use Simconnect to know when it is pressed (hence opening or closing the tool)?
Alternatively, is there a way to run an application instead of setting a url as source?