Repeated action on macro in palette

I have a macro to select all text in an input box of a dialogue box. While the selection exists, the text cursor is moved one position to the left, so that the last character isn’t selected anymore.

I want to be able to repeat this cursor movement so that I can deselect the last two, three, ... characters of the current selection.

Is it possible to set a variable when a palette is opened?

I've found this solution ...

First I create a macro that is triggered when the New term dialogue box is opened:

Screenshot 2020-03-25 at 14.27.49

It sets the variable newTermOpened to 1.

From the palette I call the macro to shrink the selection in two input boxes by one character (from the right). It then sets the variable newTermOpened to 2. Each subsequent time I call the macro (without closing the palette/ dialogue box), the action 'Select all' will be omitted.