I would like to create a macro that list items with check boxes, and then the checked items are pasted in a document. I see where you can do checked item, but I can't figure out how to get the checked items pasted.
I took a look this possible solution, but involves inputting text. I don't want that.
Thanks, mrpasini. Yeah, variable and pasting actions are where I'm getting stuck. Here's what I have so far. I know the numbers are for the check boxes, but how do I get the macro to paste the selected name?
Not sure what you mean. I should of added that I want to have say about 10+ names with a checkbox for each. And I might say check four or five of those names and have them pasted. How might that work?
Although you can't see it in the image, please note that there is a line break after the names in the If/Then actions to ensure that each name gets added on its own line rather than all on the same line. I also used a local variable for "NamesToPaste" because "NamesToPaste" needs to start fresh every time this macro is run, or else you'll end up with repeats and doubled names. If you haven't yet upgraded to KM8, you'll need to make sure to set "NamesToPaste" to %Delete% at the end of the macro.
Oh wow, thank you so much for putting it together. I can’t wait to get this try tomorrow morning. I’ll study it to understand what I was missing. Really appreciate it. And yes, I’ve upgraded to KM 8
This question ended up tickling the engineer part of my brain even after I made the earlier macro, and I was compelled to see if I could improve on it. Fortunately, thanks to @peternlewis's help, I was able to significantly improve it by eliminating the need to manually add new If/Then actions for every name added to the checklist. With this version, all you have to do is ensure that you prefix your name variables with Name__ (don't worry, the two underscores ensures that they'll still look like just the names in the prompt) and the macro will do the rest. If you're going to study a version of the macro, this is the one to do so
Here is another method, which shows how a little AppleScript can go a long way.
I found the script to be simpler/shorter than the equivalent KM Actions.
AppleScript To Get List of Checked KM Variable Names
property ptyScriptName : "Get List of KM Variable Names with Prefix and Value"
property ptyScriptVer : "1.0"
property ptyScriptDate : "2017-10-12"
property ptyScriptAuthor : "JMichaelTX"
(*
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
PURPOSE:
• Returns a list of KM Variable Names that:
• Start with specified Prefix
• Have a value of "1"
AUTHOR: JMichaelTX
REQUIRED KM VARIABLES:
• Local__ItemPrefix -- the prefix of the variable names
REQUIRES:
• KM 8.0.3+
• macOS 10.11.6+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*)
property ptyKMValue : "1" -- required value of all KM Variables
set kmInst to system attribute "KMINSTANCE"
tell application "Keyboard Maestro Engine"
set kmPrefix to getvariable "Local__ItemPrefix" instance kmInst
set kmNameList to name of every variable whose name starts with kmPrefix and value is ptyKMValue
end tell
set AppleScript's text item delimiters to linefeed
return kmNameList as text
Hey @JMichaelTX - how do I modify your applescript so it returns the values in the order they were clicked? I have used this for multiple values and it returns them out of the order in which I clicked them. I think it is trying to order them alphabetically?
@ccstone Hi Chris - thanks heaps for replying! Does this mean that the applescript wont be able to retain the items I have selected in the order I have selected them, when it passes them on to the next action?