I have a macro which prompts the user to make several selections from lists which contain 10 or fewer items.
The macro contains multiple "prompt with list" actions. For example, the first one will prompt with a list of 10 colors. The second will prompt with a list of 10 model numbers, and so on.
However I would like to reduce the number of keystrokes needed to traverse these lists, i.e. so that instead of needing to select an item then press Enter to complete the decision, I can just press a number on the number pad to immediately make the selection and have the macro automatically move on to the next list.
You will probably get some different answers. One will involve a Custom HTML action. One will involve using a button for each option. One might involve the Display Progess Bar button.
Another would involve two macro groups—one that activates another. Take a look at my ColorSetter macro for an example. This lets me quickly select a color for an action with a single keystroke.
I guess I was wrong about the KM Prompt action supporting single key shortcuts. (I thought it did, but now I think it doesn't.)
I can't even find a single key solution using AppleScript. However I didn't promise there would be such a solution.
No doubt there's a way to do this using Custom HTML actions. I'll ponder it for a bit.
Rob says there's a way to do it by using KM groups which activate and deactivate each other. That's handy, but I don't see how it will show you your options. I think you want visual prompts.
Using palettes would probably work too, and I may ponder that, but I'm not skilled with them.
EDIT: I found a way to do it with Custom HTML prompts. But I know that you don't want to mess with HTML directly, so I'll try to come up with a macro that converts your list of items into a Custom HTML prompt. It will look something like this:
Very Cool. In any case, I'm still pondering the HTML solution. It's a lot of work, but I think I can handle it.
Here's my solution. (I admit, I got some help from AI, but I also had to do some work myself. It's just a basic solution to prove that it's possible. Adding fluff and colours and calculating the window size in advance is fluff that I didn't include at this time.)
I heard it too, before I uploaded it, and I think that's the sound macOS generates when an app doesn't accept a keystroke. I wasn't sure if that was the Custom HTML app, or the app that appears directly behind it on the screen (the one that appears frontmost when the Custom HTML window closes.) At this point I have no idea how to fix it.
Good catch. I didn't notice that. That's a bug in the Javascript, I guess. I can look at it, but there's only a 50% chance I can fix it.
I wonder if there might be an easier solution using the shell? The 'nl' command is a line numbering filter which can be used to prefix numbers to lines which are fed to it. For example, when I run ls | nl -nrn -w3 -s '. ' in a given directory, I get the following output:
If you have fewer than 10 items, you could put all of those items into a variable (on separate lines), then use a shell command to add numerical prefixes (as per the above), and then feed that into the Prompt With List macro. Typing the numerical prefix will then allow you to select the item.
For example, if you have the list stored in a KM variable named 'testVar', then if you evaluate the following in the shell:
echo "$KMVAR_testVar" | nl -nrn -w3 -s '. '
You'll get a numbered list generated. You could then capture that in another KM variable, which you feed into the "Prompt with list" macro.
One "gotcha" is that the selected item will contain the numerical prefix, which is probably not what you want. So you will then need to strip off the numerical prefix in order to get the selected data, but that's doable via regex search and replace.