Macro help needed BooleanDifference

Something I do frequently is → select a group of objects → click BooleanDifference → select 1 object to subtract → Enter → ShrinkTrimmedSrf → Hide. I am trying to write a macro to automate this sequence after the group selection. what I have at present is
! _BooleanDifference _Pause _ShrinkTrimmedSrf _Hide
It executes the boolean properly but ends there. What am I missing to have this run to completion?

TIA
Robb

I think adding a _SelLast after the BD should probably do it. Not in front of my computer now.

The objects are still selected after the BD. Adding the _SelLast made no difference.

Apparently you need another _Pause:

! _BooleanDifference _Pause _Pause _ShrinkTrimmedSrf _Hide

This is because BD expects first base object selection, and if there is preselection that first Pause is automatically ‘eaten’ by the command.

You might ask - how did I figure that out? F2 (command history) is your friend. After running the macro and failing I pressed F2 and got this:

Command: _BooleanDifference
Command: _Pause
Select surfaces or polysurfaces to subtract with ( DeleteInput=No ): _ShrinkTrimmedSrf
Select surfaces or polysurfaces to subtract with ( DeleteInput=No ): _Hide
Select surfaces or polysurfaces to subtract with ( DeleteInput=No )
Select surfaces or polysurfaces to subtract with. Press Enter when done ( DeleteInput=No )
Boolean difference in progress... Press Esc to cancel
Creating meshes... Press Esc to cancel

You can see from the above that despite the preselection, the first Pause gets ‘eaten’, and then when it comes time to select the second object(s), _ShrinkTrimmedSrf and Hide have already been ‘eaten’ so they don’t get executed.

Adding the second pause gets you this as a result when you pres F2:

Command: _BooleanDifference
Command: _Pause
Select surfaces or polysurfaces to subtract with ( DeleteInput=No ): _Pause
Select surfaces or polysurfaces to subtract with ( DeleteInput=No )
Select surfaces or polysurfaces to subtract with. Press Enter when done ( DeleteInput=No )
Boolean difference in progress... Press Esc to cancel
Creating meshes... Press Esc to cancel
Command: _ShrinkTrimmedSrf
Shrunk 8 surfaces.  12 surfaces are already shrunk.
Creating meshes... Press Esc to cancel
Command: _Hide

Of course this only works with a preselected group of base objects, so it will fail if they are not. To have something that works with either pre- or post-selection, you would need something like this:

! _Select _Pause _BooleanDifference _Pause _Pause _ShrinkTrimmedSrf _Hide

But in any case, if you have to undo the macro, you end up having to undo 3 operations. This illustrates the limitations of macros, and why, for most things that are multi-operation, I end up doing this with scripts. Yep, the learning curve is steep, but in the end you have a lot more power and flexibility.

It works perfectly as you described. Good to know about the F2 - never worked that lane before. Your point about pre-selection or post is well taken.
As I am building functionality to share with others in my group, what would the script look like? I am unclear as to the difference between macros and scripting in this kind of simple command line chain.
Many thanks for your help with this.