Paste Checked Items

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

Here's the complete macro:

Example Output

MACRO:   Get List of Items Checked on Prompt

Version Date of Release
1.0 2017-10-12

DOWNLOAD:

Get List of Items Checked on Prompt.kmmacros (11 KB)
Note: This Macro was uploaded in a DISABLED state. You must enable before it can be triggered.


image

5 Likes