This is a good idea, but I think it can be improved. There's no need to go through Preview.app when KM can create image files from the clipboard on its own (note: requires Keyboard Maestro 8):
Copy as Image, Save to File.kmmacros (10.2 KB)
AppleScript Used to Get Macro and Action Names:
tell application "Keyboard Maestro"
#Check to see if selection is a macro or macro actions
set kmSelection to selection
set kmSelectionClass to class of item 1 of kmSelection
#If selection is macro, get macro name, end script
if kmSelectionClass is "macro" then
return name of item 1 of kmSelection
#Otherwise, get names of all selected actions
set ActionNames to ""
repeat with i from 1 to (length of kmSelection)
if ActionNames is "" then
set ActionNames to name of item i of kmSelection
set ActionNames to ActionNames & ", " & name of item i of kmSelection
By default this macro will automatically name the new image file using the selected macro name or actions, but it also includes an optional prompt that can be enabled to enter a name for the image file manually (make sure to disable the AppleScript action if you go that route).