Hi 
You can use the [IGet] command to query the state of many interface items. What info you get will depend on the item but for a switch like DynaMesh it will return 1 when it’s on and 0 when it’s off. So you then can use that in an [If… statement like this (as an example, I am masking the whole of a subtool when DynaMesh is off):
[IButton,DoAllSubTools,“Popup info about this button”,
[Loop,[SubToolGetCount],
[SubToolSelect,[Var,n]]
[If,[IExists,Tool:Geometry: Dynamesh],//check there is DynaMesh for this subtool
[If,[IGet,Tool:Geometry:Dynamesh]==1,//if DynaMesh is ON
//do nothing
,//else DynaMesh is OFF
//do something
[IPress,Tool:Masking:Mask All]
]//end if DynaMesh ON
]//end if DynaMesh exists
,n]//end loop
]//end button
HTH,