I thought the command: set macroList to selectedMacros
would give me a list of Macro objects.
But it does NOT. It just returns the UUID for each of the macros.
So here's how I got the current macro object:
tell application "Keyboard Maestro"
# Ver 1.1 2017-09-20
set macroList to every macro whose selected is true
--- Make Sure Only ONE Macro is Selected ---
if ((count of macroList) = 1) then
set oMacro to item 1 of macroList
else
error "Multiple Macros are selected. Select only ONE and re-execute this script."
end if
--- Now We can Get/Set Macro Properties ---
set macroName to name of oMacro
return macroName
end tell
There not commands, they are properties of the application.
selection is a fairly standard property, and is part of the standard suite.
The other two are there as well. They probably should be in the Keyboard Maestro Suite application class instead, but I’m not changing that at this point (it’s probably safe enough to move it, but there is no sense doing it now without time for proper testing).
IME, yes, the application class has a property of selection. But in all cases I just checked, it is for selection of only one element class. What really mislead me is that there is a command for selectedMacros, so it never occurred to me to look for an Application property to select macros.
While I think the current design is misleading and makes it hard for users to discover the AppleScript access to KM, I suppose the important thing at this point is to provide extensive documentation in the Wiki so others will know what’s available.
Any other goodies hidden as properties of other classes?
I hope Chis can rejoin us soon, since he is the best person to fully explore and understand the new scripting model.
Peter, the initial statement I used to get a list of selected macros seems to be equivalent to the later one you gave me:
tell application "Keyboard Maestro"
--- These Selection Statements Seem to be Equivalent ---
set macroList2 to every macro whose selected is true -- my initial statement
set macroList1 to selected macros
end tell
selection returns the currently selected objects. In an OSA compliant application, that means whatever is selected can be returned.
selection is how OSA is supposed to work. The old stuff is not, and even the selected macros is not how OSA is supposed to work, but OSA has issues with verbosity.
Well, that’s an unfortunate side effect of backward compatibility.
I could just delete it, but that seems unnecessary.
There is a start on the wiki, including some meta-programming stuff for creating macros.
Absolutely. This whole section of 8.0 could be dedicated to Chris.
Only performance, they should give the same result.
Just made a new topic that may be relevant to this discussion, as it contains macros that use scripts that in turn make use of KM8’s new editor scripting abilities: KM8: Copy, Paste, and Batch-Delete Triggers