Getting Metadata from a Keyboard Maestro Plug-in

This question is one that probably only @peternlewis can answer, but anyone else feel free to chip in...

In a plug I am writing I want to display a dialog using an AppleScript statement like this:

display dialog "some message" with icon filename

where filename is derived from the name of the file containing the icon as specified in the KM Action plist file. Getting the path to where the plug in files are stored is easy enough, but getting that filename, without "hacking" the plist file seems impossible.

Is the name of that (and any of the other metadata apart from the parameters) accessible to my code?

I am currently using AppleScript for my plug in code, so a solution using that would be preferable.

Thanks.

The best way would be to include the name you want in a hidden parameter in the Plug In plist.

1 Like

Hey @tiffle,

I've not played with plug-ins as yet, so I don't know if there are any pitfalls.

But here's some basic AppleScript to get a value from a plist.

Note that the script gets the path to itself and uses that to find the plist file.

It then extracts the value of a key with a given name at the root level of the plist.

-Chris


--------------------------------------------------------
# Auth: Christopher Stone
# dCre: 2020/11/16 01:44
# dMod: 2020/11/16 01:44 
# Appl: Keyboard Maestro
# Task: Extract a Hidden Key Value from a Keyboard Maestro Plug-In Plist.
# Libs: None
# Osax: None
# Tags: @Applescript, @Script, @Extract, @Hidden, @Key, @Keyboard_Maestro, @Plug-In, @Plist
--------------------------------------------------------

set scriptPath to path to me

tell application "Finder"
   set myPlist to ((parent of scriptPath as text) & "Keyboard Maestro Action.plist")
end tell

tell application "System Events"
   tell property list file myPlist
      tell property list item "Hidden"
         set myHiddenInfo to its value
      end tell
   end tell
end tell

--------------------------------------------------------
1 Like

Thanks @ccstone! As a relative newcomer to AppleScript there's a lot for me to learn and I imagined that getting stuff out of a plist file would be much harder than you have demonstrated. So this will come in very useful. Thanks again :smiley:

1 Like