self-defined Macro: How to add ENTER? How to assign Shortcut key?

I created a simple 2-step macro (via Tools → Macros) which I need to run VERY frequently, so I want to minimize the number of clicks it takes to execute.

  1. The 2nd step is creating a label for the selected range. This command ends with the cursor in the label field, expecting me to type in a label text. But all I want is to press ENTER to leave the label without text (empty). How can I get the “ENTER” command into the macro (as a 3rd step)?
  2. (How) can I assign a keyboard shortcut to execute my macro without having to go through Tools → Apply Macro → each time?

Thanks for any suggestions.
PS: using Audacity 2.3.3 on Win8.1

I’m pretty sure Macros can’t do conditional branching. There is no IF the program asks you something, DO that.

I think it’s the same problem people have automating Noise Reduction. Current Noise Reduction is in two steps, but you can only automate one of them.

https://manual.audacityteam.org/man/macros.html

Read through that blue box at the top. You might be able to create your job in Python rather than plain Macros.

I don’t see anything about launching from a hot key.

Koz

What are the exact commands in your macro?

I’d recommend updating to the current “Audacity 2.4.2” as there are a number of improvements to Macros: Audacity ® | Download for Windows


See here: Shortcuts Preferences - Audacity Manual

I’m not looking for a way to branch. All I want is to get my cursor out of the label text field at the end of the macro without having to hit the ENTER key.

Here is the macro:

  1. Repair (this requires making a selection, so the selection is still there after the command)
  2. “Textmarke bei Auswahl hinzufügen” which I’d say corresponds to “set label at selection” (I don’t know the exact term used in the English GUI)
    – END –

step 2 leaves the cursor blinking in the label text field, expecting me to type in some text. I can leave this field (without entering text) by manually hitting ENTER. Can I get this done inside the macro?

Thanks @steve for having me scrutinize again the keyboard settings dialog. I was at lost how to find my macro there - now I found it :slight_smile:
And I did update to 2.4.2.

One way to do what you want is like this:

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

macro.png
When setting the parameters in the Nyquist Prompt, do it like this:

prompt.png

Sorry, but I don’t quite get your point, @steve.
Do you suggest I add a Nyquist prompt (with the given parameters) as the last command in my macro?
When I did, it didn’t make a difference: after creation of the label the cursor (= the focus) is still in the label field.
Going back with the cursor to the audio track I can make my next selection OK, but I use the keyboard a lot, so I quite frequently find myself typing into the label field, when I’d had rather moved the focus out before. So ideally I’d like to get the focus out of the label track, back into the audio track.

My “point” is that the macro:

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

does what you asked in your original post.

To create the Macro correctly, try this:

Open the folder
C:Users**\AppData\Roaming\audacity\Macros**
and find the text file that corresponds with your macro.
Open the file in a plain text editor (for example NotePad++), and replace the current text with:

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

then save the file.

Hmm…Interesting - now it works indeed :wink:
Would you mind explaining a bit how the NyquistPrompt command does the magic of creating an empty label without capturing the focus?
Wouldn’t have epxected this from looking at the command line …
Thanks again!

Super :slight_smile:


Sure.
The Nyquist Prompt allows us to enter any valid Nyquist command, or even a complete Nyquist program, without having to install a Nyquist plug-in. It’s like a “temporary plug-in”.

When a Nyquist script run (either a single command or multiple commands), Nyquist returns one “result” to Audacity. This is called the script’s “return value”.

There are several different types of return value, and Audacity handles them in different ways.

  • If the return value is a sound, Audacity replaces the selected audio with that sound.
  • If the return value is a number, Audacity displays the number in a message window.
  • If the return value is a “string” (text), Audacity displays the string in a message window.
  • If the return value is a list that conforms to a specific form, Audacity creates one or more labels.

In this case, Nyquist is returning a list in the “special form” required to create one label.
See: Missing features - Audacity Support

The part of the code that creates the specially formed list is:

(list (list 0 (get-duration 1) ""))

Wow - this is cool. Not that I fully understand how you exactly this “appropriately formatted” list get create, but I guess I don’t have to :slight_smile:
Thanks, Steve, for completely getting my question answered - again! :ugeek:
Happy New Year!