I've got an unpublished macro that I'll likely share in the Keyboard Maestro Editor Megathread, but my current implementation uses a fragile method to select the first action within a selectedGroup action.
Is there a way to do this with with AppleScript (or any other robust method)?
tell application "Keyboard Maestro"
set theSelection to the selection
if theSelection ≠ {} then
set theSelection to item 1 of theSelection
if class of theSelection is action then
tell theSelection to set action1 to its first action
end if
end if
end tell
That'll throw an error if an "If", "Catch", or similar is selected rather than a "Group". It may not matter for @_jims's use-case, and the only way I can see to be reliably specific it's a "Group" action would be to test for all of thenactions, catchactions etc being missing values. Probably easier to handle the error in some way!
Yes, well – I answered the question that was asked...
This is not panacea for all possibilities, but it gives the general idea:
tell application "Keyboard Maestro"
set theSelection to the selection
if theSelection ≠ {} then
set theSelection to item 1 of theSelection
if (count of theSelection's thenactions's actions) > 0 then
select theSelection's thenactions's actions's item 1
else if (count of theSelection's elseactions's actions) > 0 then
select theSelection's elseactions's actions's item 1
else if (count of theSelection's tryactions's actions) > 0 then
select theSelection's tryactions's actions's item 1
else if (count of theSelection's catchactions's actions) > 0 then
select theSelection's catchactions's actions's item 1
end if
end if
end tell