I’ll get back again as soon as I find out how to put the KM-Action and KM-Macro data-types back on the Clipboard.
-Chris
---------------------------------------------------------------------------------
# Auth: Christopher Stone { Heavy Lifting by Shane Stanley }
# dCre: 2016/06/03 22:05
# dMod: 2016/06/03 22:33
# Appl: Keyboard Maestro
# Task: Extract Keyboard Maestro action or macro plist from the clipboard.
# Aojc: True
# Libs: None
# Osax: None
# Tags: @Applescript, @Script, @ASObjC, @Extract, @Keyboard_Maestro, @Plist
---------------------------------------------------------------------------------
use framework "Foundation"
use scripting additions
---------------------------------------------------------------------------------
set kmPlistStr to missing value
set systemPasteBoard to current application's NSPasteboard's generalPasteboard()
if (systemPasteBoard's canReadItemWithDataConformingToTypes:{"com.stairways.keyboardmaestro.actionarray"}) as boolean then
# Copied Action or Actions
set kmPlistStr to systemPasteBoard's stringForType:"com.stairways.keyboardmaestro.actionarray"
else if (systemPasteBoard's canReadItemWithDataConformingToTypes:{"com.stairways.keyboardmaestro.macrosarray"}) as boolean then
# Copied Macro or Macros
set kmPlistStr to systemPasteBoard's stringForType:"com.stairways.keyboardmaestro.macrosarray"
end if
if kmPlistStr ≠ missing value then
return kmPlistStr as text
else
beep
end if
---------------------------------------------------------------------------------
Hey Chris, maybe I missed something, but I thought the objective was to read the plist/XML to get the sub-macro name, and then open that macro for editing.
Okay, let’s build upon the “Extract Keyboard Maestro action or macro plist from the clipboard” script.
Open a macro that has an Execute a Macro action in it.
Select that action.
Copy it to the Clipboard.
Run the script.
Find yourself editing the macro called by the selected Execute a Macro action.
-Chris
---------------------------------------------------------------------------------
# Auth: Christopher Stone { Heavy Lifting by Shane Stanley }
# dCre: 2016/06/03 22:05
# dMod: 2016/06/04 01:16
# Appl: Keyboard Maestro
# Task: GO-TO macro of selected “Execute a Macro” action in the Keyboard Maestro Editor.
# Aojc: True
# Libs: None
# Osax: None
# Tags: @Applescript, @Script, @ASObjC, @Extract, @Keyboard_Maestro, @Plist
---------------------------------------------------------------------------------
use AppleScript version "2.4"
use framework "Foundation"
use scripting additions
---------------------------------------------------------------------------------
set kmPlistStr to missing value
set actionUUID to missing value
set systemPasteBoard to current application's NSPasteboard's generalPasteboard()
if (systemPasteBoard's canReadItemWithDataConformingToTypes:{"com.stairways.keyboardmaestro.actionarray"}) as boolean then
# Copied Action or Actions
set kmPlistStr to systemPasteBoard's stringForType:"com.stairways.keyboardmaestro.actionarray"
end if
if kmPlistStr ≠ missing value then
set kmPlistStr to kmPlistStr as text
tell application "System Events"
set actionPlistRecord to value of (make property list item with properties {text:kmPlistStr})
set actionUUID to MacroUID of item 1 of actionPlistRecord
end tell
if actionUUID ≠ missing value then
tell application "Keyboard Maestro"
editMacro actionUUID
end tell
end if
else
beep
end if
---------------------------------------------------------------------------------
@peternlewis - If we start deciphering KM’s Clipboard format like this, what kind of headache will this cause either you or us in the future? Do you see yourself needing to change the clipboard format itself? I realize the values in the plists will change, but what about the format itself?
I want a palette, or something palette-like, where I can put the names of the macros I’m currently working on, so I click or double-click a macro and jump right to it in the editor.
Pie-in-the-sky, I’d be able to drag-re-order the list, drag macros to it, remove macros from it, etc.
I have to admit that although just about anything is possible, I don’t expect to get this. But “you have not because you ask not”, so, I’m putting this out there.
I make no promises on the internal format of the macro files, not on the format or arrangement of the Keyboard Maestro preferences folder.
Enjoy whatever you like for as long as it lasts, but if it makes sense to change the format at some point in the future, it’ll change and any macros or workflows that depend on it will have to be reworked - I can’t afford to have progress of Keyboard Maestro limited by this sort of thing. I could just say “its all private, don’t touch”, but you may as well get as much value out of it as you can in the mean time, and that time might be decades for all I know.
I haven’t paid any attention to the “solved” checkbox — what is the effect of checking it? I will check it for this one forthwith. I use Dan’s macro every day and am delighted to have it. i am willing for us to take the hit if the underlying data formats change — they won’t change often enough to matter.
It seems like I was able to right click once and go to referenced macro kind of like command+r does in the Finder for aliases. I came here searching for that but I guess I was dreaming.
By the way I love in Keyboard Maestro 8 that you can Comtion (Command+Option (⌥)) + drag a macro to another macro to reference it, very intuitive and just the same as you would in the Finder way to go Peter!