Copy Number to Clipboard Macro

I have a json file that looks like this:

{"value1":"100", "value2":"150", "value3":"200"}

I want to do a macro that brings up a menu. When I select, for example, value1 then 100 should be copied to clipboard. When I select, for example, value2 then 150 should be copied to clipboard.

I have had a go at doing macro but it isn't working. What am I doing wrong?

Copy number to clipboard Macro (v10.2)

Copy number to clipboard.kmmacros (3.8 KB)

Your Prompt With List action uses the menuNumber variable whereas it should be using the menuText variable I think. Also change the first action to use menuText.

Changed both of them as per attached, but still get error. Any idea what else is going wrong?

Here's a trimmed down version of your macro, which is working for me with your sample JSON. By using local rather than global variables you can avoid some strange scoping effects and remove the need for that first-action reset (ignore all that if you need globals for some reason!), and I've put the chosen value straight to the clipboard:

Copy number to clipboard shortened.kmmacros (3.0 KB)


If it doesn't work for you, check your JSON (or try with that sample you posted). If that's OK then we'll need to know what isn't working and what any error is.

1 Like

Thanks that works