Macro creates a new label track for each label

About a year ago I posted a related request, which unfortunately didn’t get any replies.
Since a Nyquist command is involved, I try again in this category - hoping to bring this to the attention of some seasoned Nyquist experts like @steve :slight_smile:
How to use the macro:

  1. Select a range small enough suitable for the “repair” effect
  2. apply the macro
    ==> for the selected range “repair” is applied and a range-label is created on a label track.

The question is:
How do I need to change this macro, so that for each execution the label (marking the repaired selection) is created in the same label track:

Repair:Use_Preset="<Factory Defaults>"
NyquistPrompt:Command=";type analyze\n(list (list 0 (get-duration 1) \"\"))" Parameters="" Version="4"

I have these two lines in a *.txt file, import it into Audacity and assign a keyboard shortcut to it because I need to use it very frequently.
A year and several releases later I resumed experiments with selections of v3.2.5 to 3.7.3, even tried v2.4.2 - all of them show the same behavior: Each invocation of the macro creates a range-label for the repaired selection on a new label track. So after 20 invocations I have 20 label tracks …

I am 100% sure that this macro did work correctly (i.e. putting all labels in a single track) in some v2.x versions, because this was the current version when I started to de-crack dozens of vinyl recordings many years ago. Unfortunatley I don’t remember what it was, that stopped it working for the first time.

But maybe nowadays there is a totally different solution possible to achieve the same goal?
I am open to a new solution as well.

Use the Add Label at Selection macro command to label a selected region. The Add Label at Selection command adds labels to the first label track below the selection - if there isn’t an existing label track below the selected audio, a new label track is created below the selected audio.

OMG - I knew there was a simple solution. :person_facepalming:
Actually in the list of my experimental macros I found one with exactly those two lines.
Probably I got them confused at some point and got stuck on the wrong one…
Thanks a lot @steve for your prompt solution, as always!

a small follow-up question: After creating the label, I’d like to move on to the next selection to repair whithout entering a name for the label. “Add label at selection” however puts my cursor in the label field and therefore prevents me from scrolling right (CTRL+wheel), unless I hit “return” to get my cursor out there.
Is there a way to programmatically “hit ENTER/RETURN” or avoid getting my focus “caught” by the label?

See if this works for your use case:

... (your script)
AddLabel:
SelectTracks:Mode="Set" Track="0" TrackCount="1"

The last line selects the top track, which moves focus away from the label, to that track.

Yep, perfect - thanks again!