I'm trying to build a macro to help me extract my Found Image images from Editor into external images and replace the Found Image Image with a reference to the path. When I copy the image from the Found Image Image field with CMD+C, I'd like to have KM then:
Copy the Group and Macro titles to variables
Create a new Preview image from the clipboard (Found Image)
Save the image to specific folder and with a filename incorporating the Macro Group and Macro names.
Step 1 is where I'm struggling. How can I copy the currently selected macro's name and group name?
I try my best to help with things like this, but today I can only give you some tips.
The KM Editor is an AppleScript-enabled program so you can probably use AppleScript to help you here, especially with step 1. However I'm a noob at AppleScript so other people will have to help you here.
The macro group and macro name do not uniquely identify your image, because you could have more than one image per macro. So you have to think of a way to address that.
I'm trying to do the same thing as @iampariah. I think this returns the name of the executing macro group, which in this case would be the macro which performs the task, rather than the macro which is being acted upon, whose group we're trying to deduce. My research has come up short too.
As far as I can see Pariah's last macro works, although it's a bit of a workaround.
This task can be accomplished directly using AppleScript.
--------------------------------------------------------
# Auth: Christopher Stone
# dCre: 2022/03/18 21:14
# dMod: 2022/03/18 21:14
# Appl: Keyboard Maestro, Keyboard Maestro Engine
# Task: Get Macro Name Selected Macro and Its Macro Group Name
# Libs: None
# Osax: None
# Tags: @Applescript, @Script, @Keyboard_Maestro, @Keyboard_Maestro_Engine, @Get, @Macro, @Name, @Selected, @Group
--------------------------------------------------------
tell application "Keyboard Maestro"
set selected_Macros to selectedMacros
if length of selected_Macros is 1 then
set macroUUID to item 1 of selected_Macros
set macroRef to macro id macroUUID
set macroName to name of macroRef
set macroGroupName to name of macro group of macroRef
else
display notification "Problem with number of selected macros!" with title "Keyboard Maestro" subtitle "ยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยท" sound name "Tink"
end if
end tell
# Send variables to Keyboard Maestro:
set kmInstance to system attribute "KMINSTANCE"
tell application "Keyboard Maestro Engine"
setvariable "local_MacroName" instance kmInstance to macroName
setvariable "local_MacroGroupName" instance kmInstance to macroGroupName
end tell
--------------------------------------------------------