Problem with expand/collapse all (Groups)

Hello
I have two buttons on a toolbar, with codes 'Go GROUPCOLLAPSE *' and 'Go GROUPEXPAND *' respectively.
At the moment, they do not recognise whether the current display is grouped or not...

Say i group the file display according to any criterion, both buttons remain grayed out UNLESS I first refresh the file display (Go Refresh), after which they become clickable.

Likewise If i then set the grouping to 'none', the two buttons remain clickable (which they shouldn't, since there is nothing to expand/collapse), unless i again refresh.

Try this code (the buttons remain clickable, but you don't have to refresh):

dopusrt /cmd Go GROUPCOLLAPSE *

and:

dopusrt /cmd Go GROUPEXPAND *

Thanks for the response.
That indeed helps, though I would prefer it if the buttons are clickable only when display is grouped (and greyed out when not).

Furthermore, ideally, the 'collapse all' would be highlighted (and/or unclickable) if all groups are already collapsed (and similarly 'expand all' highlighted when all expanded).

P.S I think it is useful when the buttons affecting display are dynamically 'aware' of the current display - either via the 'click-state' OR 'highlighting'. As is currently the case for most other buttons