You can’t add code to plugin buttons or find out the code. But for many of the actions you could record a macro which, with a bit of zscript knowledge, you could then edit to do what you wanted. ZScript is not difficult and you can find out all about it here:
http://docs.pixologic.com/user-guide/customizing-zbrush/zscripting/
For SubTool Master, you can assign a hotkey to the actions you use most. In ZBrush 4R5, the buttons are directly available in the ZPlugin>SubTool Master sub-palette. For earlier versions you can make the buttons appear so you can assign a hotkey by clicking the version number at the bottom of the SubTool Master pop-up interface.