All you need to do is put in a test so that if the button or slider is in one state then your macro sets the other state. You use the [If statement like this:
Code:
[If,[IGet,Tool:Polypaint:Colorize] == 1,//the button will return 1 if it's on
[IUnPress,Tool:Polypaint:Colorize]
,//else it's off so turn it on
[IPress,Tool:Polypaint:Colorize]
]
and for the brush masking
Code:
[If,[IGet,Brush:Auto Masking:Mask By Polygroups] == 0,
[ISet,Brush:Auto Masking:Mask By Polygroups,100]
,//else set to zero
[ISet,Brush:Auto Masking:Mask By Polygroups,0]
]
Note that the brush masking toggle will turn off if the slider is set to any value above 0.
HTH,